Need help: Differentiating Duplicate Actors
Hey all, i'm still trying to make a tower defense game and having trouble determining targeting patterns. I've tried overlap targeting and range targeting. I've gotten both to work....kind of.
The issue i'm having is getting the Actors to not share the same targeting booleans and targeting coordinates.
So lets say i have two actors. Gun & Target. I can get the gun to only fire at the target when its in range. However when i place a second gun thats out of range....it fires at the target thats overlapped the first gun, even though its out of range.
So as far as i can tell i can alleviate the issue if i can get the game to recognize and assign identification of ;actors that are duplicated.
And no, creating multiple actors is not an option. ie: gun1, gun2, gun3
The issue i'm having is getting the Actors to not share the same targeting booleans and targeting coordinates.
So lets say i have two actors. Gun & Target. I can get the gun to only fire at the target when its in range. However when i place a second gun thats out of range....it fires at the target thats overlapped the first gun, even though its out of range.
So as far as i can tell i can alleviate the issue if i can get the game to recognize and assign identification of ;actors that are duplicated.
And no, creating multiple actors is not an option. ie: gun1, gun2, gun3
Comments
if self.ID=2
constrain game.target2x to self.positionX
constrain game.target2y to self.positionY
then in the gun have a rule that says
if self.ID=2
and self.magnitudeBetweenGunandTarget2 < 50 (you'll have to create this and set it up using the magnitude function)
change self.StartFiring to True
TSB, if i use self attributes how do i get the gun to see what self attributes are in the target?
Assign a self attribute to the gun actor called 'active'.
You'll then need to set up a rule in the gun that says if the enemy is within the gun range self.active is true, otherwise it equals false.
Then make the rule that if the gun's self.active = true, do all the stuff you currently have to make it fire.
So the 'active' attribute is only true if a target is within it's range, so the second gun should not start shooting until it's own 'active' attribute is set to true.
my circumvent was to create a grid of boxes that the gun would shoot at if the targets overlapped. and if the targets themselves got hit in the path of the shot then they'd be destroyed. the grid wouldnt go anywhere.
however looking at what it would require to make a grid accurate enough to make it believable would be 1,628 actors (not counting guns and targets). My system used 4 game level attributes per grid unit as well as 3 self attributes. lol lets avoid that.
works great if you have one gun and lots of targets or lots of guns and one target but not both.
What exactly happens when you have one gun with multiple enemies?
the same works for the gun x/y since each target will only calculate one range to one gun. the others just get ignored.
what i need is a way to say. if ANY target enters range of Gun shoot at it. but communicating the coordinates for one specific target seems to be out of GS capabilities.
it would be so much easier if i could figure out a way for the targets to uniquely identify themselves as soon as they were generated and then the gun can say, if any target is in my range match my ID to match its ID then request coordinates and fire.
i think thats kinda what scitunes was getting at but...its proving difficult.
They could uniquely identify themselves by having a global attribute called say 'enemySpawnCount' and every time a target is spawned it adds one to that enemy count, then tells itself to set it's own ID to that enemy count. So I guess you have an attribute that keeps track of the number of targets currently on screen, whilst this count the total number spawned across the entire length of the game.
So the first target to spawn will set game.enemySpawnCount to 1 and then set it's own self.ID to 1, the next to spawn add +1 to game.enemySpawnCount again making it 2 and then it's own self.ID to 2 and so on.
Then you could link that ID up to the gun when the target comes into it's range as you suggested.
What I found helped when I was making my game was after I'd got a basic thing working to a degree and figured out exactly everything I would need to trigger events etc. I wrote it all down and started fresh from the notes I'd made. As I found going back and editing rules here and there was getting messy and confusing.
The gun cant directly look inside the target for an attribute.
That is a really tricky one. I have to concede, I really don't know I'm sorry. I'm sure there must be a way, but it's beyond my skills.