When player moves, in most games, he moves forward - regardless of any curved geometry under his feet. Thats what i want to achieve.
-
Initialy i have vector A (direction of movenent parallel to vertical surface S).
-
When i meet green surface with normal N, i need to change direction to vector B, which must have following conditions:
a) Vector B must be parallel to Green surface with normal N.
b) Vector B must stay parallel to S surface, which is just vertical surface.
how to do that?
// i have following variables:
Vector3 position; // lies on surface S.
Vector3 a; // initial movement direction.
Vector3 n; // normal of green surface.
// i need to calculate this new direction, along green surface, but only "vertical along", meening that must be conditions: b.x == a.x, b.z == a.z; All i need in other words, is just to change angle between Y axis (Vector3.up), so it would be along green surface.
Vector3 b = new Vector3(a.x, ??? , a.z); // ???
In other words, my character must flow up and down along his direction, but not “left-right”. I.e. he must not change his “horizontal” XZ direction, he must change only Y direction, no matter on which surface he is moving on.
Other words - i just need vector of intersection of S and B surfaces, using only variables that i have.