#Not detecting enemies
1 messages · Page 1 of 1 (latest)
You probably just aren't connecting the signal when you instantiate the tower node, could you share your instancing code and your scene tree?
sorry for taing long to respond just checked the thread but ill get that to you as sson as possible
taking*
this is the code
and what tree do you want me to send?
@leaden patio
@leaden patio
i dont know how to show how the signal is connected but this is the tree
Where do you set placed to true?
No, like where in the code do you set placed to true?
And this is in the Angler script?
@sterile spire Ok I'm still not seeing any red flags, what does you attack code look like?
Oh and are you seeing 1 and 2 printed?
extends Node2D
var placed = true
var Enemies = []
var target
#func range_entered(area):
#if placed == true:
#print("1")
#if area.is_in_group("enemy"):
#print("2")
#Enemies.append(area)
func _process(delta):
if placed == true:
if Enemies != []:
target = Enemies[0]
look_at(target.global_position)
else:
global_position = get_global_mouse_position()
func _input(event):
if event.is_action_pressed("click"):
placed = true
func range_exited(area):
if area.is_in_group("enemy"):
if placed == true:
Enemies.erase(area)
func shoot():
if placed == true:
const BLAST = preload("res://Scenes/angler_bullet.tscn")
var new_blast = BLAST.instantiate()
new_blast.global_position = %Bulb.global_position
new_blast.global_rotation = %Bulb.global_rotation
%Bulb.add_child(new_blast)
func reload():
if placed == true:
if Enemies != []:
shoot()
func _on_area_2d_2_area_shape_entered(area_rid, area, area_shape_index, local_shape_index):
if placed == true:
print("1")
if area.is_in_group("enemy"):
print("2")
Enemies.append(area)
this is the entirety of the anglers code