Does anyone know how to make a simple trampoline?
Ive been trying to figure out how for a while now but can’t get it.
So if someone could help me I would really appreciate it.
Hmm, I think its should be something like that:
When the player is in collision with the trampoline, then y (jump) axis will increase.
Do something like that:
var jumpSpeed = 50;
function OnCollisionEnter(hit : Collider) {
if (hit.gameObject.Tag == "Trampoline") {
gameObject.transform.position.y += jumpSpeed;
}
}
- It may has errors, sorry*
Orel.
There was only 1 error but I fixed that. And if I touch the platform it doesn’t make me jump but if i drop a sphere or something else with the tag Trampoline on it then it’ll make me jump, but it’s not jumping it’s like it’s setting my position above my map.
Any ideas?
Hello,
You’ll want to use a rigidbody.
Typed in a web browser:
var jumpSpeed : float = 1.0;
function OnCollisionEnter(col : Collision){
col.rigidbody.AddForce(jumpSpeed * Vector3.up, ForceMode.VelocityChange);
}
You can also multiply the force by the impact of the collision to make the player bounce harder the harder they land.
Best wishes,
-Lincoln Green
Alright, it works for other objects but not for the FPS controller.
So could you maybe explain to me how to use it?