im creating2d ufo game and im trying to make the spaceship fire
i created a prefab of bullet and add a rigidbody component.
created an empty object in the hierarchy and attached the script to it.
the creation of bullets from the prefab succeded but i cant write the right code in order to manipulet each cloneBullet velocity. they stay static on the screen
i tried in my code to make each bullet move the same direction just for testing it. it doesnt work.
and can u give some direction how to manipulet all bullets in each frame
![alt text][1]
this is my code:
using UnityEngine;
using System.Collections;
public class FireController : MonoBehaviour {
public Transform Bullet;
public GameObject player;
private GameObject Bulletclone;
string direction;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.F))
{
Bulletclone = Instantiate(Bullet, player.transform.position, Bullet.rotation) as GameObject;
Bulletclone.GetComponent().velocity = new Vector2(0, 20);
}
[1]: /storage/temp/62718-new-bitmap-image.jpg
↧