Bounce Mechanic(General Question)

Hi all,
I’m trying to make something like FireEscape.

I’m trying to emulate the bounce off the umbrella…so far with no success. I’ve tried a flat surface and a curved surface…but both don’t successfully duplicate the ‘feel’ of the bounce. How would you duplicate this in Unity???

Sorry for how general this question is…

when using rigidbody physics, there are two basic places you can adjust bounciness:

http://docs.unity3d.com/Documentation/Components/class-PhysicMaterial.html

2: adjust the bounce threshhold in the physics manager if necessary

http://docs.unity3d.com/Documentation/Components/class-PhysicsManager.html

Something like

function OnTriggerEnter( other : Collider ) {
other.rigidbody.velocity.y *= -0.9;
}

Attached to the umbrella object. Then set the collider on the umbrella to be a trigger (check the box by Is Trigger).

Edit -
Or fiddle with actual-physics settings like the other answer.

This is clearly a “faked manual bounce” and not a physically correct bounce. They all bounce back to the exact same height were they jumped off, even when the angle changed.

There are several ways. A simple box collider for the umbrella would be the best. Make it a trigger and just flip the y-speed. Additionally you would add some speed on the x (or z) axis depending on the side of the umbrella and the distance from the center. Just flipping the y speed will keeping the momentum / energy so it always bounce up to the same height.

``````// C#
// [...]
public float sideScale = 0.5f;

void OnTriggerEnter(Collider aObj)
{
var RB = aObj.rigidbody;
if (RB == null)
return; // not a rigidbody
var speed = RB.velocity;
speed.y *= -1; //flip
var relPos = RB.transform.position.x - transform.position.x;
speed.x += relPos * sideScale;
RB.velocity = speed;
}
``````

edit
Here’s the UnityScript version. It’s actually almost the same

``````// UnityScript
// [...]
var sideScale = 0.5f;

function OnTriggerEnter(aObj : Collider)
{
var RB = aObj.rigidbody;
if (RB == null)
return; // not a rigidbody
var speed = RB.velocity;
speed.y *= -1; //flip
var relPos = RB.transform.position.x - transform.position.x;
speed.x += relPos * sideScale;
RB.velocity = speed;
}
``````

the easiest method i use for bounce is
detecting collision at point of collision,
save that velocity, use Vector3.reflect, use new velocity, it will reflect as a perfect bounce, if you want to use a factor of bounciness then, multiply the new vector for your factor