I challenge the community to come up with a solution for this problem - I’ve tried all kinds of things with no luck, and I thought I’d put it out to you guys to see if we can figure out a solution.
The idea is simple: have a ball bounce around in a triangle like some sort of 3D pong - rotate the triangle with “A” and “D”.
The challenge is this: Overcome the shortcomings of Unity’s collision detection - in this case, when the triangle is moving, collisions with the ball are very inconsistent, not always bouncing the ball back into the middle but going through the wall instead.
It may sound easy, but it hasn’t been for me…
Thanks and good luck! - the project is attached to help you get going!
377786–13081–$ballintriangle_146.unitypackage (14.1 KB)
Are you trying to use regular movement controls/scripting with physics objects?
Not really - the only reason I was using physics objects was so I could use collision data - also, because its recommended not to use static colliders for objects that move.
I want the ball and walls to move at fixed rates through transform functions - moving the objects isn’t the problem, but thanks for clearing that up.
I guess the problem basically comes down to collision detection between the ball and the moving walls - it doesn’t always happen and I don’t know why.
So after much trial and error - turned out physics was the way to go -
a kinematic rigidbody controlling the triangle with a rigidbody ball bouncing around a physics material with no friction achieved the effect I was going for
couple of things:
For the objects that you’re moving, if they have rigidbodies (which they should, even if they’re kinematic), move them in fixedupdate, not update, and move them by either applying forces (you can use ForceMode to change the way force is applied), or use MovePosition and MoveRotate if you want exact movements. See the rigidbody page in the scripting reference for more info.
Then, if that’s still having problems:
http://www.unifycommunity.com/wiki/index.php?title=DontGoThroughThings