- Home /
Vertical 3-way/lane movement?
Hi there!
I have a code for my characters movement, which currently looks like this:
void FixedUpdate () {
//0 i Y vil sige at vi ikke kan bevæge os i Y-aksen, altså ikke hoppe!
input = new Vector3 (Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
if(rigidbody.velocity.magnitude < maxSpeed)
{
rigidbody.AddForce(input * moveSpeed);
}
//Dø hvis Players transform y er lavere end -2 (altså hvis han falder udover banens kant)
if (transform.position.y < -2)
{
Die();
}
Physics.gravity = Physics.Raycast(transform.position, Vector3.down, .55f) ? Vector3.zero : new Vector3(0,-60f,0);
}
He's moving fine and dandy, but I was wondering if there's a way to make the player move a certain amount in the vertical direction, when pressing Up and Down?
I wish to make 3 lines/paths in the z-axis the player can jump "in and out" of, then run along on the x-axis as usual.
Here's a picture of what I mean:

Any help is appreciated!
Thanks.
problem.jpg
(68.1 kB)
Comment
Your answer