I am working with the Lerpz Jump pad and I came across this code and couldn’t figure out what is actually making Lerpz jump.
Here is the trigger of the collider and a call to a function in the ThirdPersonController called SuperJump(). I don’t see the part were it says “ok lerpz jump!”
function OnTriggerEnter (col : Collider)
{
var controller : ThirdPersonController = col.GetComponent(ThirdPersonController);
if (controller != null)
{
if (audio)
{
audio.Play();
}
controller.SuperJump(jumpHeight);
}
}
Here is a snippet from the ThirdPersonController script where SuperJump() is defined. Again I don’t see the part that actually tells Lerpz to Jump. It looks like it stores a variable with the jump calculations but then doesn’t do anything with them?
function SuperJump (height : float)
{
verticalSpeed = CalculateJumpVerticalSpeed (height);
collisionFlags = CollisionFlags.None;
SendMessage("DidJump", SendMessageOptions.DontRequireReceiver);
}
What simple thing am I missing?
I have not done this tutorial yet, but its next on my list. I would like to take a guess though and say that once his verticalspeed > 0 he will move up till gravity pulls him back down.
so this line is making him jump…
verticalSpeed = CalculateJumpVerticalSpeed (height);
Thanks for the post roto23. I’m stumped. The only other thing I can think of at the moment is maybe there is something listening for “DidJump” and using the values in verticalSpeed. I need to check it on Monday.
Also, does anyone know how to make the unitron editor move passed the first search result? Like if there’s more than one of the same term that’s returned by the search.
have you looked inside the function…
CalculateJumpVerticalSpeed ()
roto23 was correct in his first post: take a look at ThirdPersonController.js, line 337. You will see that verticalSpeed is used to update the position, so changing it to a positive value results in a jump.
Hey andor, I don’t have unity in front of me right now but I thought that variables started with with lowercase according to the convention that Unity developers use. That would make vericalSpeed a variable and therefore only store calculations. I don’t see where verticalSpeed is calling another function for the Jump. This is were I got lost. I will have a look at line 337 on Monday.
I think I got it now. The controller.Move() in the thirdpersonController.js is run every Update(). I need to look at the moveDirection variable a little more. I don’t quite understand how it’s getting it’s values.
var movement = moveDirection * moveSpeed + Vector3 (0, verticalSpeed, 0) + inAirVelocity;
movement *= Time.deltaTime;
// Move the controller
var controller : CharacterController = GetComponent(CharacterController);
wallJumpContactNormal = Vector3.zero;
collisionFlags = controller.Move(movement);