I Have a REALLY basic script in C# that basically spawn a bullet, and then move it. (Basically a shoot)
It doesn't matter if you click the mouse button as fast as you can, it will not shoot so fast, but it still is fast, and when i make the reloading system, it will be a chaos. So, i've been trying to put a delay in the script.
Example:
THE BULLET IS SPAWNED.
THE BULLET IS SHOOT.
WAIT FOR 1.3 SECONDS
ANOTHER BULLET IS SPAWNED
ANOTHER BULLET IS SHOOT
ETC...
But i can't get it to work! I cannot understand what to do! I already read the manual but it doesn't help a all, as (in my opinion), it's saying to me to create a script to make another script to work or something like that. I can't figure out what i need to do! Can someone explain me how can i do this? I would appreciate if anyone could complete the script =|
using UnityEngine;
using System.Collections;
public class ShootDemo : MonoBehaviour
{
public Rigidbody projectile;
public float speed = 0;
// Update is called once per frame
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
Rigidbody instantiatedProjectile = Instantiate(projectile, transform.position, transform.rotation) as Rigidbody;
instantiatedProjectile.velocity = transform.TransformDirection(new Vector3(0, 0, speed));
}
}
}
↧