I will start this topic saying: I forgot most of my math knowledge ![]()
![]()
I am messing with a ball moving inside a cube, bouncing around. I have a shape that I use to affect its trajectory and make it change course.
Sometimes the angle is really acute and I get unwanted movement, for example, bouncing really hard on Y but barely moving across the Z direction.
The way I have this setup is that the ball is reflecting via the following script:
tempVelocity = Vector3.Reflect(other.relativeVelocity*-1.01f, other.contacts[0].normal);// Adds a little force every time
rb.velocity = tempVelocity; // assign the ball's velocity the new value
What kind of operation can I do to the normal I receive to limits its result within a certain constrain, letās say, limit it within 60 degrees? I know the idea behind it: I have to take the normal, take the direction the ball is coming in from, calculate the angle between both, then see if it is between the threshold, otherwise equal it to the min or max number I define. But not really sure how to get the ballās incoming angle and how to operate between the two.
What units does Unity use anyway, Cartesian or polar? I know you can convert, but I forgot how (Iām sure thereās a function that does it already built in!).
Thanks in advance for the help and sorry for the n00bness. Itās been a while since I have done all these things.
