Creating a bounce part to bounce off floor and walls

I’d like to be able to make a surface that will repel the player with an equal opposite force to that the player hit with.

Essentially I want to be able to make a player fall from a height of e.g. 64 studs, hit the surface, and bounce back up to the original height of 64 studs, not gaining or losing any height.

I also want to be able to make a player rebound off it if they fling into a wall coated in the surface.

An example of this concept would be the Repulsion Gel (The blue one) from Portal 2.


Here is an example of what I want to achieve.

I hope you can help me out!

My current attempt for floor bouncing was to detect when there was no floor under the player, get their height, wait until touching a bounce surface and then use the height difference to calculate the desired velocity. It didn’t work at all, so I won’t link it.

3 Likes

This article by egomoose shows you how to do this using Dot Products.
image

1 Like

ok, ill try this out. Thanks! --

1 Like

I’m not too sure how to implement this though. I don’t know how to reflect off of the surface when the player hits it because I don’t know how to cast the ray. I can’t have a set direction for the ray because the character could face any direction. This issue leads onto my other issue which is how to get the normal a part hits without rays.

I can’t reflect a ray if I can’t shoot the ray to begin with is my issue.

1 Like

Bumping. I wanna know the answer too.

2 Likes