0 votes

So i was making my first simple fps game . And after coding the bullets , it always collide with the fist kinematic body but then it rarely collide with the others . Here is an example


In my code the Ennemies(Kinematic Body) always register when it collide for the score so i guess the problem is with the bullets code :

extends Area
var speed = 100
var velocity = Vector3()
onready var timer = get_node("Timer")

func start(xform):
    transform = xform
    velocity = + transform.basis.x * speed

func _process(delta):
    transform.origin += velocity * delta

func _on_Bullets_body_entered(body):
    if body.get_name() == "Ennemy1":

func _on_Timer_timeout():
in Engine by (20 points)

1 Answer

0 votes
Best answer
func _on_Bullets_body_entered(body):
    if body.get_name() == "Ennemy1":

The problem must comes from the condition, I guess all your enemies haven't "Enemy1" as name in the node tree.
You should change this condition.

For example you could add your enemy in a group and check if the body belong to this group.

by (288 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.