I’m trying to make a 3D tower defense game, but I don’t know how to code the First Targeting system, i have targetPoint for the enemy’s to walk to and the enemys move with the AI move to, pls some help
tower has variable “currentTarget” of type “your enemy base class”
on tower tick:
if currentTarget is valid:
if currentTarget has gone out of range:
set current target to nullptr // stop targetting things that went out of range
if currentTarget is not valid:
for each actor "potentialTarget" of type "your enemy base class":
if potentialTarget is in range:
if currentTarget is not valid:
currentTarget = potentialTarget // target the first thing that we can target
else if distance to potentialTarget < distance to currentTarget:
currentTarget = potentialTarget // retarget to the closer target
if currentTarget is valid && canShoot:
do shooting
Hi, please avoid creating multiple Posts for same topic
Your original post with more answers: Tower Defence First target
Instead of that - bump it with update (changing title, description or adding a comment is enough to bring it back to top)