|
|
|
 |
Reply From: |
jgodfrey |
If your bullets are actual, moving objects relying on collisions to detect hits than too much speed can indeed cause hits to not be detected. That’s because, due to the high speed, the bullet may be on one side of the target in frame N
and on the other side of the target in frame N+1
, without ever having actually collided with the target.
The typical fix for this is to explicitly track the bullet’s previous position and its current position (in each frame). In the case where no collision was detected in the current frame, you’d additionally create a Raycast
between those two positions and see if it hits your target. If so, that’s a case where the collision was missed using the normal methods.
When that’s detected, you can change the position of the bullet to the point of the actual collision, and trigger your normal collision response.
thanks for your reply but I could understand that totally, I’m very new in Godot, do you know any solution to this problem, thanks in advance.
Hossein Vatani | 2020-11-20 18:42
Do I know a solution? Yeah, that’s what I attempted to describe above…
jgodfrey | 2020-11-20 18:46
thanks anyway
Hossein Vatani | 2020-11-20 19:33
Hmmm… What I described is a very typical way of solving exactly the problem you describe. If you have specific questions about the described solution, I’m happy to try and clarify things as necessary.
But, if you want a solution to your problem, something like I described above is likely what you’ll need to do. So, understanding it will be important to solving your problem.
jgodfrey | 2020-11-20 19:45
many thanks for your time. I got your point, and I’m on your explanation to understand it, code may solve my present problem, but understanding the problem has more efficiency
Hossein Vatani | 2020-11-20 20:02
There is one other simple thing you could try that might fix your problem. You could try changing the value of the continuous collision detection mode on your rigidbody bullets.
There are more precise settings available, though they are slower than the default setting.
See here for details:
RigidBody2D — Godot Engine (stable) documentation in English
As documented, you can use get_continuous_collision_detection_mode(value)
to change the mode to one that’s more precise.
I might suggest trying mode 1
, but I don’t know for sure whether it’ll work for you.
jgodfrey | 2020-11-20 20:16