Best way to check enemy hit player

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

In a shooting game, suppose the enemy is throwing some sort of fireball to the player, with a speed the player can manage to get rid off. What’s the best way to check if player is hitten?
I have two options in mind:

  • a KinematicBody attached to the bullet, and use areas to check
  • collision a RayCast with vector magnitude increasing as bullet proceed
  • other?
:bust_in_silhouette: Reply From: magicalogic

Since a bullets behavior is fairly simple (Just moves forward with a certain velocity until it hits something, then spawn some particles and then die.) and since you want them moving at a low velocity, I would recommend just using an Area node.

Two know when it hits something you just the area_entered and body_entered signals to a method that spawns a particle system for the fire effects and the queue free the bullet.

Also it doesn’t make much of a difference if you use a kinematic body instead.