Jump Pad Direction

In the third person controller. I’d like to alter the jump pad script to propel the character in the Y direction of the jump pad. Anyone know how I would go about this?

Thanks!
Mike

If I understand your question, you could do this:

function OnTriggerEnter (col : Collider) 
{
	var controller : ThirdPersonController = col.GetComponent(ThirdPersonController);
	if (controller != null)
        {
		// throw him in the air...
                // controller.SuperJump(jumpHeight);

                // throw him in the air the direction the pad is oriented
		// find the 'up' for this object
		var normal : Vector3 = transform.TransformDirection(Vector3.up);
                controller.Launch(normal * jumpHeight);


       }
}


function Update()
{
	// show us where this pad is pointing...
	Debug.DrawRay (transform.position, transform.TransformDirection(Vector3.up) * jumpHeight);
}

In the contoller code, I just repurposed (read: hacked) the inAirVelocity to start with the launch vector instead of Vector.Zero and added a function:

function Launch (launchVector : Vector3)
{
	inAirVelocity  = launchVector;
	collisionFlags = CollisionFlags.None;
	SendMessage("DidJump", SendMessageOptions.DontRequireReceiver);
}

I went in and tilted the jump pad and it looks like it has the behavior you were looking for.

Hope this helps!

Edit: Removed double post of TriggerEnter function… silly cut and paste!

That works really well! Thanks! :smile:

Mike

Sorry, but when I used this code in Jumppad script, he showed me this:
"Assets/Scripts/Misc/Jumppad.js(11,24): UCE0001: ‘;’ expected. Insert a semicolon at the end."e Here’s that line:
Vector3 normal = “transform.TransformDirection(Vector3.up);”
What should I do?

Sorry, but when I used this code in Jumppad script, he showed me this:
"Assets/Scripts/Misc/Jumppad.js(11,24): UCE0001: ';' expected. Insert a semicolon at the end." Here’s that line:

Vector3 normal = "transform.TransformDirection(Vector3.up);"

What should I do?[/code]

From your snippet, it looks like you put quotes around the method call. Don’t do that :slight_smile:

Vector3 normal = transform.TransformDirection(Vector3.up);

(no quotes)

No, no. I’ve just added quotes.

Ah… .js vs .cs

Try this:
var normal : Vector3 = transform.TransformDirection(Vector3.up);

Yeah, it works. Thank you. :slight_smile: