Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

Having an issue with instantiating objects on button clicks

$
0
0
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

Viewing all articles
Browse latest Browse all 508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>