Question by
austincarp · Jun 07, 2017 at 06:28 AM ·
2d2d gamecodepage
How to make bullet move?
So ive been trying to make my bullets work for 2 weeks now but they dont move. They spawn and dont move what should I do?
heres my code
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class BulletSpawn : MonoBehaviour { public GameObject bullet; private float timer = 0; // Use this for initialization void Start () {
}
// Update is called once per frame
void Update ()
{
timer = timer + Time.deltaTime;
if (Input.GetKey ("space") && timer > .3) {
Instantiate (bullet, new Vector3 (transform.position.x, transform.position.y, transform.position.z), Quaternion.identity);
timer = 0;
}
}
}
Comment
Where is the code to move the bullet? right now you are just instantiating the bullet.