system
1
I am creating a game where the player must climb to the top by bouncing on the floating platforms. I wish to have it so when the player hits the platform they will bounce up x units.
The code I had:
var bounce : int = 10;
function OnCollisionEnter (other : Collision) {
if(other.gameObject.tag == "Bounceable") {
transform.position.y = bounce * Time.smoothDeltaTime;
}
}
does not work correctly. As soon as the player hits the defined object he just appears 10 units above the object, with no smooth jumping effect at all. I also want to be able to control the character on his way up and back down but I do not know how to do this as it just teleports.
poncho
3
the problem about using, adding force or modifying velocity is that only works for the horizontal or vertical collisions, when you try to make it collide with a pline like 45 / or \ there goes a lot of problems cuz there is need for sin and cos equations and some other vector stuff, the unity physics for the bounce can be add in this way
Asset>Create>Physics Material, then to the object change the bounciness to a value more than 0 and drag the new material to the object you want to make it bounce,
the problem with this is that if you lauch an object it will stop in a few bounces cuz there are alot of things as friction, drag, angular drag, mass that stop it
hope it help
qJake
2
You want to use something like Rigidbody.AddForce. This will let you "push" the object upwards using a force value you specify. Be sure to change the ForceMode to something like Impulse (basically burst-force), otherwise you won't notice it at all.
You could also set the Rigidbody's velocity manually, specifying a velocity of something like (0, -10, 0) to make it move in an upwardly direction.
You can create a Physics material and change the Bouncing