Hey There! I’m trying to use BodyMovers to make a rebound effect with a projectile.
I have a ball which I am giving the force so that it will hit a wall with angle Theta, as shown below (the blue angle).
My problem is “How do I find the angle of collision?”
I’ve read some posts about this, and one said “Raycast it to the wall and then find :Dot()”. I get that, but how do I get the direction of the ray I have to cast?
If I get the angle of collision, I can flip it and raycast to the flipped direction, and then use BodyPosition to get it there, however the start is where I’m having a problem. Thanks for the help!
EDIT 1:
I have managed to make a part which uses CFrame.LookAt to visualize the angle to incidence.
You might get interested in LookVector which is a property of CFrame to find out the direction of the ray that you are to cast.
Or if your cube relies on physics so you cannot predict the rotation of the cube, you should get direction by subtracting the previous position of delta time beforehand from the current position.
Good point, you can the velocity the ball is going with and use that as your rayDirection. So like, if the velocity = Vector3.new(0,500,0) then Vector3.new(0,500,0) is your rayDirection.