- Home /
how to get a perpendicular vector for wall-jumping
Basically, i have a Vector3 that its x and z components' slope (im not quite sure how any of this even works) runs parallel to the wall. I want to jump off the wall perpendicularly (I'm using char controller object so no forces) but I can't figure out how to get a perpendicular Vector3 (in the sense that if y is ignored it would be perpendicular to the x and z components of the parallel vector 3. how would i do this??? thanks in advance
Answer by NickWu · Mar 02, 2016 at 08:54 PM
Are you trying to get a vector3 perpendicular to the wall? If so, one way of doing it is to do a raycast down to the wall surface and get the normal from the hitinfo.
Answer by phil_me_up · Feb 28, 2016 at 01:53 AM
I think you probably want to look at Cross Products. A quick Google search should give you the mathematical basics.
Unity provides this through Vector3.Cross(A, B) (from memory, I might be wrong about naming though so check the API).
It's worth knowing that Cross(A,B) doesn't equal Cross(B,A), so be sure to get your parameters the right way round.