Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | SebSharper |
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.
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?
I don’t know, but i use vector.bounce method and pass collision normal
To give me bounce from that point
xCode Soul | 2020-12-08 09:01