Locking the Z-axis based on direction

 0 I'm having a bit of trouble figuring out the maths for this one.I have a series of nodes, each one has a position and direction, the player is always linked to one of these nodes, and can be anywhere on the line it describes (x direction) or above or below it (y direction), but cannot move into the foreground/background (z direction) relative to the direction the node is pointing I've got the moving in 1 axis working, but I need to snap the player to the relative Z of the object (no matter where they are on the line) Movement is done with the following code: ``````void Update() { float Direction = Input.GetAxis("Horizontal"); this.transform.position += (CurrentNode.transform.rotation * Vector3.forward) * Direction * Time.deltaTime * Speed; } ``````this is not as simple as setting the z = 0, as that only works if the player is facing left/right relative to the game space.I've thought about using 2 rays and finding their intersection point (Node ray is node position and node rotation, Player ray is Player Position* and Player rotation * Vector3.Left) but afaik the Ray class hasn't got an intersecting function.Vector Math has never been my strong point sadly and I'd appreciate any help. more ▼ asked Jul 01 '12 at 07:46 PM Canazza 76 ● 1 ● 3 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

Be the first one to answer this question

By Email:

Topics:

x1042
x286
x185
x125
x62

asked: Jul 01 '12 at 07:46 PM

Seen: 372 times

Last Updated: Jul 01 '12 at 07:47 PM