x


Stoping character with Platformer Controller script attached. 2,5D ladder.

Hi. I want to make climbable ladder. I have code like that:

var ladder : Collider;
var onLadder = false; 

function OnTriggerStay (ladder) {
    if (Input.GetAxis("Vertical") > 0){
        onLadder = true;
    }
}

function OnTriggerExit (ladder) {
    onLadder = false; 
}

function FixedUpdate(){
    if (onLadder){ 
        PlatformerControllerMovement.velocity =  Vector3.Slerp(PlatformerControllerMovement.velocity, Vector3.zero, 1);
        PlatformerControllerMovement.gravity = 0;
    }
}

But it doesn't work. I want to stop the character, but it only slows.

What should I do to stop the character imedietly?

more ▼

asked Apr 15 '10 at 02:35 PM

Rafal Sankowski gravatar image

Rafal Sankowski
23 3 3 11

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

The third parameter in Lerp/Slerp is a number from 0 to 1. In your code it is always 0, meaning it will always return the first parameter.

more ▼

answered Apr 15 '10 at 07:10 PM

Molix gravatar image

Molix
4.8k 16 27 66

It's the same effect with the third parameter set to 0.25, 0.5, 0.75 and 1.

Apr 15 '10 at 10:44 PM Rafal Sankowski

If you set the velocity to 0 (Vector3.zero) here, and it is still moving, then it must be set to non-zero somewhere else, e.g. does your PlatformerControllerMovement script know to stop moving the character?

Apr 16 '10 at 05:24 PM Molix
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5072
x1035
x186
x25

asked: Apr 15 '10 at 02:35 PM

Seen: 1518 times

Last Updated: Apr 15 '10 at 10:51 PM