I have a game where the player controls a part that goes at pretty high speeds throughout a track. The part itself has an AlignOrientation constraint inside of it to make sure it never turns the wrong direction by accident. Throughout the track there are several barriers/walls on the side, and the problem comes when the player manages to collide with said barriers.
Here is what I have (simplified):
Here is what I want to achieve:
My idea to prevent this was to cast a ray from the part when it collides with a wall, then rotate the surface normal of the ray around 90 degrees so that it points sideways and apply a force to the part in said direction, however I want to know if there is a more efficient way of solving this problem.
That is what I had in mind, however there are several problems with this solution, mainly the fact that the result of the cross will always return right no matter what, and there would be situations where I would want the part to be pushed left instead and I have no clue on how to implement such a system
Okay I figured it out, I did what I already thought of (getting the normal and crossing it), then got the walls CFrame in the part’s object space and applied a force in the direction of the cross multiplied by a math.sign() of the CFrame’s position Z coordinate.