so im trying to get my enemy actor to shoot my hero actor within a certain distance... i been looking on the forums for about 20 minutes but i give up... in the picture below the hero actor is on the left and the enemy is on the right but i want it to be that distance
I think you can create a giant square or circle (that is invisible) around the hero that when collides with the enemy activates an attribute that tells him (the enemy) to shoot. Or two (one left, other right). (You should first calculate the pixel distance).
Comments
I don't really know, but I have an idea:
I think you can create a giant square or circle (that is invisible) around the hero that when collides with the enemy activates an attribute that tells him (the enemy) to shoot. Or two (one left, other right). (You should first calculate the pixel distance).
Hope it works.
This distance between them is . . .
abs(enemy - hero)
. . . so just check to see if this is smaller than a certain value and if it is then get blasting !
@socks i have no idea how to write that in code lol
Not at my computer right now, so off the top of my head (mistakes included !) it should look something like this . . .
If abs (enemy.position.X - self.position.X) is smaller than 100 . . .
The do some stuff !