Ricocheting a projectile

https://streamable.com/ax6rib
I have a koopa shell as seen in the video above and I want to make it ricochet back and forth against the walls. I tried destroying the body velocity after its shot out and changing elasticity and friction but the momentum is lost too quick. Please show me what I could do

Change the force to go left or right every time it hits a wall.

1 Like

You can raycast in the direction the shell is moving, and then use the normal from the raycast result.

1 Like

raycast is very performance heavy

1 Like

Not really, proven by modules like FastCast and Raycast Hitbox. They don’t take up that much performance if the length is small, and the physics calculations of an actually moving object probably take up way more performance.

3 Likes

This is false. (Word count needed)

2 Likes

This is what I read from the wiki/devhub.

1 Like

Ok so luckily I have good memory and remembered there was a Roblox Developer’s Journal years ago where the user Catblox goes over how to achieve this with raycasts, so maybe you can give it a read and hopefully it’ll help you!

1 Like

i see how to cast a ray and reflect it based on the hit but how would i move the koopa shell along the ray

maybe at the end of the raycast, whatever it hits creates a small transparent part for the koopa to look at, then apply velocity/body movers. (i dont know if this will work though just something random I came up with)

Adjust the BodyVelocity’s velocity according to the raycast result.