So, I am trying to create a wallrun script. To set the char’s velocity I want to make the velocity relative to ray’s Normal value, but it has to be modified to turn right or left, not front. Ray’s normal is an directional vector. How could I do this?
If all of the walls are vertical you could use cross product to get the vector perpendicular to two other vectors
norm:Cross(Vector3.new(0,1,0))
would get the vector perpendicular to both the normal vector and a vector pointing directly upwards
This vector will always be pointing to the right, so you can use the cross product vector for the D key, and the -cross product vector for the A key
You could also use the Vector3.new(0,1,0) for going up and the Vector3.new(0,-1,0) for going down
If your walls aren’t all vertical, you could perhaps use the UpVector of the wall part (assuming all of your wall parts are properly facing upwards) rather than Vector3.new(0,1,0)
The norm:Cross(Vector3.new(0,1,0))
would work even if the walls weren’t perfectly vertical