Theres a button in my scene and I want to instantiate an object when I press it but it returns the error:
Type IPointerClickHandler expected Button received. i:0. The variable bullet of helicopter has not been assigned.
You probably need to assign the missile variable of the helicopter script in the inspector
public Rigidbody bullet;
public void fire()
{
Rigidbody clone;
clone = Instantiate(bullet, transform.position, transform.rotation) as Rigidbody;
clone.velocity = transform.TransformDirection(Vector3.forward * 10);
}
I have the bullet prefab on my object in the inspector and my button uses the function above when clicked so I don't know what the problem is, if anyone could help, I'd appreciate it
↧