+1 vote

So, ummmm...

I have a problem with raycast. I'm creating a simple game and i want to attack enemy's.
I create enemy and everything works fine but... If I duplicated him the raycast gone wrong.

The script cannot detect duplicated enemy's raycast. If i change duplicated enemy raycast name and write it to script error show message: node not found. If i change original enemy's raycast name and write to script it works fine on original enemy but on duplicated raycast didn't want to detect collision, like raycast don't exist.

Maybe different code? it's the same with quotation marks

The game is 2D.

Photos and everything:
Duplicated enemy
Original enemy

Godot version Godot v3.2.1 - stable
in Engine by (24 points)

Code that connects to player:

func _on_SwordHit_area_entered(enemy):
target_1 = $"Raycast/RayCastLeft".is_colliding()
target_2 = $"Raycast/RayCastRight".is_colliding()
if target_1 || target_2 == true:
    health_bar.value -= 50

func _on_SwordHit_fast_area_entered(enemy):
target_1 = $Raycast/RayCastLeft.is_colliding()
target_2 = $Raycast/RayCastRight.is_colliding()
if target_1 || target_2 == true:
    health_bar.value -= 20

Only taking player node:

if laser.is_colliding():
        health.value -= 10

And taking nodes also:

onready var health = get_parent().get_parent().get_node("Player/HealthBarPlayer/HealthBar")

enter image description here

I think that area entered code can be write in player but what with taking node to enemy's healtbar and also taking damage to player's healthbar.

SORRY, laser is working so getting node is working but signal to func (area entered) are not connected. So writing script in player can solve it but what if on map are more than 1 enemy, i'm going to check it.

So it's a lot of bugs. Writing code in player didn't solve 0 dmg problem. Enemy has problem with animations and finding sprite frames,couldn't resolve track also.

enter image description here

enter image description here

Please log in or register to answer this question.

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.