Hi, I’ve thrown together something that works that will hopefully point you in the right direction. Here is what I did:
I made a new blueprint called BP_HomingMissile. The homing missile contains the following: A static mesh, A vector variable for its TargetLocation (with expose on spawn checked), a float variable for its speed (set to the number of unreal units to move each second. Mine is at 300), and the following nodes that make it move from its start location to the TargetLocation destroying itself and running its custom OnHit event dispatcher when it has reached its destination (note that this is not the best way to move something at a constant speed, but it is something I threw together quickly. Replace with any other method of moving something to somewhere else)
For the skill I’ve made a duplicate of Skill_Laser that I’ve called Skill_Homing. All I’ve done in this new blueprint is to replace the nodes that normally spawn and destroy the laser emitter with ones that spawn a homing missile and continues once the missile has hit. Like so:
If you cope the above you should have a missile that spawns when you click the target to shoot, travels to the target and then deals damage and disappears. Hope that is close to what you were after.
Thanks for the suggestion. I agree completely, and this is actually how it is already in my WIP build. The starting location of is now set in the EventBeginPlay event of the camera blueprint itself. Generally, several things will be in more sensible places in the next update.
Welcome back There are several ways you can solve this, but I’ll give you a farily simple one that should achieve what you want.
For this I’ve created a new Enum called ETerrain that holds our different terrain types. I’ve added Plain, Woods and Water by default.
Then to the Unit blueprint I’ve added a new Map called TerrainCosts, with ETerrain as the Key and Integer as the value. For each unit type you then add to the map what terrain you want the unit to be able to traverse (leaving out any that should be impassable) and set the value to whatever extra cost you want for that terrain type for that unit (keeping it at zero for default cost).
Next, I’ve added an ETerrain variable to BP_Tile where we can specify what terrain that tile represents. I’ve then made two child blueprints of BP_Tile called BP_TileWoods and BP_TileWater, set their ETerrain values to match and set their edge costs to 1.
Following this I’ve added a new array to BP_GridManager called Terrains that holds the terrain type of each tile. At the end of the event graph of BP_GridManager (does not matter where as long as it is after AddViewportTerrainToArrays) I’ve added the following:
This adds the terrain values of each of your tiles to the Terrains array, defaulting to Plain. You could of course forego using tiles and just manipulate the array directly.
The next step is to create a custom pathfinding for our units. If you have not modified it already, use the SearchAndAddAdjacentTiles(Custom1) function, which is identical to the regular pathfinding, but included for ease of adding a new type. However, we will be referencing the current unit a lot in this function, and do not want to cast to it every step of the pathfinding, so go to the CustomPathfinding macro and hook up the SetCurrentPawnPathfinding nodes in front of SearchAndAddAdjacentTiles(Custom1) just like they are in SearchAndAddAdjacentTiles(PassThroughFriendlies)
Next, in the SearchAndAddAdjacentTiles(Custom1) function add a new branch after the one checking the movement cost of the next tile to search. In the new branch, get the terrain type of the tile to be searched from the Terrains array and try to find it inm the TerrainCosts Map of CurrentPawnPathfinding. If you do not do so, abort this seach step of the pathfinding. If you find it, add its cost of moving to this tile. Like so (new nodes are highlighted. Don’t forget the ‘+’:
That should be it, I think. Except remember to set the PathfindingType of your units to Custom1. Here is a screenshot of a unit that has Forest set to 2 cost, plains to 1 and water not addet to its TerrainCosts map
Hope that is what you were looking for and that I remembered all the steps. Let me know if it works on your end
