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

How to AddForce to a Rigidbody from Game Objects Spawned from an Array, One Prefab at a Time?

$
0
0
Hello. As the question say, I need to add force to a prefabs that are spawned from an array, and they need to be added to the prefab one at a time. Let's say there's an array of 10 prefabs that are spawned and moving around. The next time the user clicks on the mouse, AddForce should be added to element 0 in the array, then the next time the mouse button is clicked AddForce should be added to element 1 in the array, so on and so forth. This should go all they way through until the end of the array. What's a good way to go about doing this? I initially thought that just adding a public bool and flipping that when the mouse button is clicked, but of course this makes it so all elements in the array are affected by the AddForce. How can I do it so only one prefab is affected on at a time? Thanks!

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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