Hi, I am having some issues with getting my enemy to make spawned towers fire separately.
Explaining it:
In my Arrow Tower BP (Arrow Fire BP), I reference an arrow that is fired from the tower’s socket.
I have a Boolean that asks if the Arrow Tower is set on board.
Next, I have a Tower Line BP. (I accidentally named it just Tower BP)
This is an overlap only actor. For when the Dark Knight overlaps it.
I get my Arrow Tower actor to get a copy of its data and use the bool reference to it.
Then I am setting true or false whether or not Dark Knight is overlapping which can trigger the Arrow Tower to fire, if set to true.
Video:
Also here is a video to help show my issue.
As you’ll see, the first tower only fires. I fixed it from firing out of every tower set. I can’t make another BP actor for this and it work. I can’t duplicate actor and set on stage and it work. I can’t duplicate on stage and it work.
I may be missing something, but why not set this bool parameter on the current Tower self? This way each tower will fire as soon as Knight overlaps them and stop fire when Knight stops overlapping them, individually.
Having a bit of an issue trying to envision what that should look like in the Arrow Tower, would you be able to give me an idea about that? i think as I understand you, I should fire the arrow from the line bp and set the overlapping in the arrow tower bp. Is that correct? Thanks
Well, for now until I can better understand advanced blueprinting, I found a way that works with making 8 towers of each, and setting each line with those corresponding towers. 8 Arrow towers on 8 lines.
Glad that you found a solution. I will still put in my two cents!
Like AyanMiru already said it seems you are getting AllActorsOfClass and then only using the first tower. So what you do is you have Tower Lines and once they overlap, you try and set a boolean on the towers in this line to get them to fire, is this correct?
You’ll need some sort of mapping between the Lines and the Towers. So each line and each tower should have a variable, a simple integer index should suffice. This should be instance editable at least for the Lines. For the (expectedly) preplaced Lines you’d override the values so the indices represent the line number. When you place a tower, you save it’s current line number too.
Then when your line overlaps, you loop through AllActorsOfClass Tower, check if the line index is the same, and only switch the boolean if it is.
If it already works for you and you don’t want to change it, it’s okay, but if you made 8 different tower BPs for each version of the tower, that’s very bad practice and in the end, leaves you with having 8 times the work when you want to implement a new tower!
Hope I could be of help and if you need more help, just ask!
Thank you for your two cents. lol I actually do appreciate it. I am trying to understand what you’re saying, I have never done any indexing so I’m new to that. But I have one question, would I be able to destroy the towers and re-spawn them with this method or should I just toggle visibility to achieve this?
If your suggestion works with destroyed actors and allows me to re-spawn them, I would rather do it that way because as you said, I want to do best practice on building and not work harder doing it.
Well, looking further into it, you have a grid of tower spawners already, so let’s just go with that.
I’d just try and give them integer variables “column” and “row” or something like that. Then your towers should have the same variables and when your spawners spawn a tower, the tower gets the same values as the spawner. (make variables instance editable and exposed on spawn, then when you SpawnActorByClass in the Tower Spawner or widget, you can directly set the values).
You should definitely call DestroyActor once you don’t need it anymore. Definitely don’t just hide it, so keep it clean there. If you want to spawn it again, just use the functionality you already have.
Now what these variables get you is you can do something like this:
It finds all Towers in the world, with the variables you can for example distinguish if they are in the correct Line, and then only trigger your shooting functionality there.
Wow, thanks. Couple of questions. So this is done in the spawners BPs all 40 of them? Should I set how many columns in column var? Same for Rows? Do I number the == or let it decide for itself? And you are saying to fire the tower if overlapped Dark Knight on True? Thanks
Well if a variable is “instance editable” you can set it from the world editor. So you can set both variables on every spawner you have already placed (as I think you’re not placing them procedurally) so the variables represent their actual row and column (not the total amount! basically all spawners have a different combination in these 2 variables). Basically each spawner knows his exact position in the grid. (I don’t know if in your case you only need Lines/Columns and no Rows at all).
The blueprint screenshot above is not done in the spawners but in the Line instead (overlap event) when you want to flip the booleans and want to find out which towers need flippin. The variables I fear you have to set by hand for each spawner.
The == (equals) I left like this just for demonstration. You can of course implement a similar variable for each Line and then the equals node would of course be used to check if the current Line and the current Tower in the loop share the same column. Only if they do, they should shoot (otherwise towers shoot without any enemies in their Lane).
The way you handle shooting seems alright. Towers only shoot arrows when IsArrowSetInLine is true, so basically all you have to do is make sure IsArrowSetInLine is only true, if it’s actually in the same line