- Home /
character jump on collision with a box
hey everyone, i have a character and a box , and what i want is when my character jump and land on the top of the box i want him to jump again without me pressing the 'space bar' ! i want him to jump(just by him self) when he collides with the box , actually im using a bounce script BUT i want him to jump not to bounce ! thanks
here's the bounce script that im using :
var bounceSpeed = 1.0;
var bounceAmount = 2.0;
function OnControllerColliderHit(hit: ControllerColliderHit){
if (hit.transform.CompareTag("crate")){
for (i = 1; i < 2; i++) {
var t = 0.0;
while (t < 1.0) {
t += Time.deltaTime * bounceSpeed;
transform.position.y = Bounce(t) * bounceAmount;
yield;
}
}
}
}
function Bounce (t : float) : float {
return Mathf.Sin(Mathf.Clamp01(t) * Mathf.PI);
}
Comment
Your answer
Follow this Question
Related Questions
gameobject destroyed on collision with character 3 Answers
Character jump on collision 1 Answer
Bouncing character like on a pogo stick 1 Answer
how the ball bounces of equal in angles? 1 Answer
Problem with my Jumping script 1 Answer