- Home /
When player enters box collider, increase player jump height.
I was trying to make a script that would access character motor and change this: var baseHeight : float = 1.0; to something like this: var baseHeight : float = 5.0;
I'm new to this, i have something like this but it doesnt do anything.`var player : Transform;
var jump = player.GetComponent("Character$$anonymous$$otor").jumping.baseheight;
function OnTriggerEnter(other : Collider) { jump=20.0; }`
Answer by Xevoius · Apr 30, 2014 at 02:48 PM
In the script that you attach to the character all you need to do is add OnTriggerEnter() and update your baseHeight variable in that function.
I hope this helps.
Hey That works, but it works on every collider how would i only make this on certain collider that is lets say named "JumpCollider". Would i need to change something in this: "other.gameObject.name"?
void OnTriggerEnter(Collider other)
{
if (other.gameObject.name == "JumpCollider")
{
motor.jumping.baseHeight = 5.0f;
}
}