Question

I got a field in unity3d that has some depressions in it (like small holes). The field's slope always leads towards the nearest depression. A sphere is dropped at random somewhere in the field, rolls around a bit until it stops in one of the depressions.

The problem is, this is taking too long. It could roll around for 5-10 seconds until it stops. I'd like to stop faster.

Any ideas how I can achieve this?

Edit: The main issue is when the ball is next to the depression, but it has speed that is 90 degrees from the hole, then it starts going in circles and takes a while to stop.

Was it helpful?

Solution

Ok, after getting some advice in the comments, and experimenting, this is the way I solved it:

  1. Apply a small measure of strength towards the depression
  2. If the current velocity is more than 30 degrees away from the center of the depression, slow the ball (apply strength in the opposite direction of the velocity)
  3. IF the ball gets very near the center of the depression, stop it and place it in the center

Thanks for all the tips. If anyone comes up with a better way, I'm still open to suggestions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top