I’m making a grappling hook and whenever my character grapples and hits the ceiling, he just drags across the ceiling, whilst I would prefer for him to have a slight bounce. I could use a physics material and add bounce, but then he’d bounce if he were to land on the floor as well, which I don’t want. If there any way to calculate whether the object being hit is above, and using that changing the bounciness?
I fixed it already.
void OnCollisionEnter (Collision other) {
//If the player hits an object above him whilst grappling, they get bounced back.
if(other.contacts[0].point.y > transform.position.y && Grappling == true) {
this.GetComponent<Rigidbody>().AddForce(new Vector3(0, other.relativeVelocity.y * 10, 0));
}
}