Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Object after instantiate doesn't apply AddForce

$
0
0
Hello, I was instantiating a prefab by UnityOfficial tutorial for Instantiate. All work except "AddForce" command. I wrote script as in the tutorial, but variable ballPrefab I made as GameObject type instead of Rigidbody. If it is Rigidbody, I can not add prefab in the inspector into it... Here is the code: public Transform spawner; public GameObject ballPrefab; void Update () { if (Input.GetButtonDown("Fire1")) { Rigidbody ballInstance; ballInstance = Instantiate(ballPrefab, spawner.transform.position, spawner.rotation) as Rigidbody; ballInstance.AddForce(spawner.forward * 3000); } }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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