0 votes

Hi. I want to reflect a bullet when it collides with an area2d I have. It should reflect, like if it was bouncing towards the exact opposite point.image
The image above is an example of how the bullet should behave when it hits the area2d.
This is the code I use when the mouse has been clicked to fire the bullet, if it is any useful:

bullet_instance.apply_impulse(Vector2(), Vector2(bullet_instance.speed + base_speed, 0).rotated(rotation))   //bullet_instance is an instance of a bullet scene, it has alredy been added to the scene tree and set the position to the gun

Also, my bullet instance stores the speed of it with the variable of the same name.
How would this work?

in Engine by (100 points)

I don’t know, but i use vector.bounce method and pass collision normal

To give me bounce from that point

1 Answer

–1 vote

isnt it https://docs.godotengine.org/en/stable/tutorials/math/vector_math.html
there's bounce option
as for radians, you just need rotation pick one in 180 - 45* < x < 180 + 45* .. somehow

by (12 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.