Quantcast
Channel: Latest Questions by Ashish4241
Viewing all articles
Browse latest Browse all 6

Supplying Input from Update To FixedUpdate

$
0
0
I want to spawn some rigidbodies and apply some initial force to them on spawning.But i want the rigidbodies to spawn in FixedUpdate and add force to them there.However I spawn them on user input and the input is taken in Update for avoiding misses as compared to FixedUpdate .So i tried and wrote the following code in C# void FixedUpdate() { while(InputCount!=0) { temp = Instantiate(bomb,childTransform.position,Quaternion.identity)as GameObject; temp.rigidbody.AddForce(this.transform.right*(-1)*forceAmount); InputCount--; } } void Update () { if(Input.GetMouseButtonDown(0)) { InputCount++; } } Here I had Single input so I just incremented its count,But in general case I intend to keep a hash map with keys with their count and supply it to FixedUpdate from Update as in above code.Is there any standard practice for doing this or I am doing it right?

Viewing all articles
Browse latest Browse all 6

Trending Articles



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