I’m pretty new to Unity, so please excuse if there is an easy solution for my question I just don’t know yet.
I am working on a VR project, in which objects spawn from random locations in the air, fall down to the floor, bounce off and finally stop moving and lie on the floor.
Is there a solution, for making these objects all come to lie on a certain side after the movement?
Many thanks and happy New Year!
You could use Transform.Rotate() of an object from its OnTriggerEnter()
You should rotate the object over a few frames, such that transform.up is aligned with the Vector3.up (the world’s up direction).
The trigger could be a spherical, and could extend 1 extra meter, beyond the object. As soon as it touches anything, your object will begin spinning to the needed orientation
HAHAHA I love this toast rain cloud idea!
Here is my solution.
If the toast lands on the wrong side, then just apply a new force to it that bounces it back up a little. Eventually every toast will land on the correct side and be stable. Maybe add a counter to your toast (if landed on wrong side then countTries++) and if countTries > 10 or something, just allow the toast to land on the bad side and then flip it over using transform rotate 180 degrees. It would actually be funny if it happens as opposed to unnatural if it happens too early.
Another way to adjust the probability of landing on one side is to think of a coin flip with a weighted coin that has more weight on one side. Add an invisible object with a heavy (more mass) rigidbody to one side of the toast and that side will fall down more likely than the other side I think.