Collision - easiest way to script that

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Vladson
:warning: Old Version Published before Godot 3 was released.

Hello, I am new in Godot and trying to figure out how to script basic collision between ENEMY nad BULLET.
Both of them have BOX collision shape.
Could someone answer me, how can I do this? I just found something about ray collision in tutorials.
Thank you.

Is your bullet “hitscan” or not? I mean, does it travel at an infinite speed or is it actually a projectile?

Calinou | 2016-03-05 15:42

It is projectile node with collision box.

Vladson | 2016-03-05 16:02

:bust_in_silhouette: Reply From: kubecz3k

If your bullets are actually a projectiles then one of the ways how this can be done is to use AreaNode as a base one. Add a CollisionShape, add Sprite (or MeshInstance), write small code to translate the bullet in every fixed_process tick and finally connect signal body_enter() to the bullet script itself. Inside the signal check if incoming body parameter is appropriate for damage and finally deal the damage (I’m usually checking if the body has_method “damage”` and if yes then I’m using it) .