I’m building a game that has ore nodes (as actors) on a map.
My AI character needs to have a list of the locations so he can go to them and mine them. Think of a mining droid. Nothing new here.
At first, on BeginPlay, I did a get all actors by class into an array which game me a nice list of all of my nodes by node type:
Copper, (X=1370.000 Y=710.000 Z=50.000)
Copper, (X=-10.000 Y=1630.000 Z=50.000)
Copper, (X=-710.000 Y=460.000 Z=50.000)
Iron, (X=-1650.000 Y=1550.000 Z=50.000)
Iron, (X=1260.000 Y=-1650.000 Z=50.000)
Iron, (X=-1250.000 Y=-1650.000 Z=50.000)
If the player wanted the robot to mine the copper nodes, all he had to do was look up all the nodes of type Copper, pass them through a function that selects the closest node and go mine it.
Then I thought “why not eliminate the get all actors by class and put this info into a DataTable , since I know where all of the nodes are from the beginning?”
I created a DataTable like this:
—,OreType,OreLocation
1,“Copper”,"(X=1370.000 Y=710.000 Z=50.000)"
2,“Copper”,"(X=-10.000 Y=1630.000 Z=50.000)"
3,“Copper”,"(X=-710.000 Y=460.000 Z=50.000)"
4,“Iron”,"(X=-1650.000 Y=1550.000 Z=50.000)"
5,“Iron”,"(X=1260.000 Y=-1650.000 Z=50.000)"
6,“Iron”,"(X=-1250.000 Y=-1650.000 Z=50.000)"
Then found out I couldn’t get all of the Copper nodes cleanly, because I can’t do a find all records by column. So I created an array, looped through all of the rows and created an array. I think I’m back to where I started from.
Is there a cleaner way to do this? (with or without blueprints, I assume I can create a C++ function)
What I want for my final result is an array of say Copper locations, or Iron locations that I can sort into distance from the droid.
Thanks ahead of time.