Bullet deflection in 3D how do i prevent it

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ouhellouder

extends RigidBody

var shoot = false

const Damage = 50
const SPEED = 100

func _ready():
set_as_toplevel(true)

hello this is my bullet code

func _physics_process(delta):
if shoot:
apply_impulse(transform.basis.z, -transform.basis.z * SPEED)

func _on_Hit_box_body_entered(body):
if body.is_in_group(“Enemy”):
body.health -= Damage
queue_free()
else:
queue_free()

but when speed is too high bulled doesnt react to colisions i already find out that its because of physics but could there be any solution for this thanks for answer

Fast projectiles such as bullets are implemented with raycasts to avoid this. Why would you use a physics object when the projectile only lives for 1-2 physics frames?

You have a couple options:

  • Replace fast projectiles with a simple raycast
  • Slow down these fast projectiles (and maybe increase their size as well to help with collision detection)
  • Use a hybrid of physics object with a raycast that checks for collision in front of it to limit its movement so it doesn’t phase through colliders.

Bernard Cloutier | 2021-12-17 15:38