#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Bounce object off ray cast relative to self?

edited July 2013 Posts: 7

I have a ray cast and all physics set up, but I want to dynamically do something like this:
http://imgur.com/wI0SudR
So when the ball overlaps with the ray cast, I want it to bounce the ball based on the side it collided with. In other words I want to apply force to a single point of the object.

Tagged:

• Posts: 2,820

First off, I'm assuming you know when the ball hits the ray cast. I'm also assuming the ball is a physics object. Next, you find the vectorized angle of the raycast and add 90ยบ to it (like the math here: http://stackoverflow.com/questions/11773889/how-to-calculate-a-vector-from-an-angle-with-another-vector-in-2d). Finally, when the ball hits the raycast, set the linear velocity of the the ball to the angle of the raycast.
Another method is simply to have an edge body type that the ball bounces off of.

• Posts: 7

@Zoyt I made it an EDGE. But the object doesn't bounce very high, can I make the edge bouncier?

• Posts: 1,595

Change the restitution of the object

• Posts: 7

Thanks! That works great