My character is being controlled with a character controller. I’m trying to do the following: “when my character is standing on top of a jump platform then he has the ability to jump significantly higher than when hes not standing on it.”
Here is my setup:
I have a game object (jump pad) with a box collider and trigger checked. I referenced the 3d platformer tutorial for some general ideas. I apply this script to the game object (jump pad):
var jumpHeight = 20.0;
function OnTriggerEnter (col : Collider)
{
var controller : PlatformerController = col.GetComponent(PlatformerController);
if (controller != null)
{
if (audio)
{
audio.Play();
}
controller.SuperJump(jumpHeight);
}
}
// Auto setup the script and associated trigger.
function Reset ()
{
if (collider == null)
gameObject.AddComponent(BoxCollider);
collider.isTrigger = true;
}
@script RequireComponent(BoxCollider)
I’m using the platformer controller script from the 2d Platformer Tutorial. the super jump function was missing from this script so i copied it over from the third person controller script. Here is the code:
function SuperJump (height : float)
{
verticalSpeed = CalculateJumpVerticalSpeed (height);
collisionFlags = CollisionFlags.None;
SendMessage("DidJump", SendMessageOptions.DontRequireReceiver);
}
function SuperJump (height : float, jumpVelocity : Vector3)
{
verticalSpeed = CalculateJumpVerticalSpeed (height);
inAirVelocity = jumpVelocity;
collisionFlags = CollisionFlags.None;
SendMessage("DidJump", SendMessageOptions.DontRequireReceiver);
}
I’m not getting any errors when compiling and I can run the game but when I jump on the “jump platform” he jumps at normal height… not the specified increased height. I am getting several warnings relating to the above script:
WARNING: Unused local variable ‘verticalSpeed’. (BCW0003)
WARNING: Unused local variable ‘collisionFlags’. (BCW0003)
WARNING: Unused local variable ‘inAirVelocity’. (BCW0003)
I’m not sure what the issue is and am hoping someone can help me out here. If there is another way to go about this I’m open to trying other things as well. Appreciate any help.