Hey guys, So how do I make it so that when I click the mouse button, the plane with the muzzle flash texture appears, then disappears? I am using a pistol so it should just be a quick animation regardless of how long i hold down the fire button for. Also, i wrote a script to instantiate the muzzle flash, and when it does that, the muzzle flash appears sideways, and then it doesn’t go away.
You can see a screen shot here:
http://www.flickr.com/photos/59578003@N08/5522960660/
And here is my script for the firing and muzzle flash (firing works, muzzle doesn’t)
using UnityEngine;
using System.Collections;
public class Shooter : MonoBehaviour {
// Use this for initialization
void Start () {
}
//public variables
public Rigidbody projectile;
public float speed = 20;
public GameObject flash;
// Update is called once per frame
void Update () {
if(Input.GetButtonDown(“Fire1”))
{
Rigidbody instantiatedProjectiles = Instantiate(projectile, transform.position, transform.rotation) as Rigidbody;
GameObject instantiatedFlash = Instantiate(flash, transform.position, transform.rotation) as GameObject;
//make the object move
instantiatedProjectiles.velocity = transform.TransformDirection(new Vector3(0,0, speed));
}
}
}
I am using C# and thanks for any help