Download

Getting 0,0,0 results with GetAllActorsOfClass Array

Hi all,

I’m trying to get the locations of actors in a class but I’m always getting 0,0,0 as a result. Here is my blueprint. As you can see, I used GetAllActorsOfClass to make an array. I then used a ForEachLoopWithBreak to go through each entry in the array. I used GetActorLocation and Cast to Hex to try to get the location of the item in the array but that didn’t work. I tried removing the CastTo but that didn’t work.

Any suggestions?

1984b4a78da8d934c9b1a61bd1fa1aa16873a6a1.png

I don’t see why the cast is needed. Actors have transforms so any type of actor should work. Also the check to see if it has any results seems unneeded. If there are no results the completed branch would happen automatically. Of course I can’t see what you’re doing with dupeCheck.

Its also hard to see what’s going on with only part of the graph. I’m interested in what happens after the branch on the right.

Thanks for the reply awilliams1701.

For the cast, I was following the instructions in the “How to Find Actors in Blueprints” doc (https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/FindingActors/Blueprints/index.html). I added the check for any results because I thought I needed to make sure it wasn’t empty. I thought I got an error without it before, but I’ll try again without it.

After the branch on the right it sets dupeCheck to be true or false depending on if it finds an existing actor in a location that was randomly chosen (Rand Vector). Maybe this isn’t the best way go about it?

The only reason you need to do a cast is if you need to do something that only your hex class can do. If you are doing location based work with the object’s point of origin, Actor has this built in.

Your explanation sounds like the problem. From what you are describing, your random vector would have to exactly match the location of one of the actors. If it’s even a fraction of a unit off, it won’t match.

I’m not sure what you are trying to do, but I will tell you a problem I had that might be similar and how I solved it. I wanted to create alarm zones that would alert guards to any discharged weapons within a particular volume. I created a BP that contains a box component and a vector. The box component is scaled between the point of origin and the vector (relative location and scale is set to half the vector with an extent of 1). For my weapon class in the fire event, it uses getOverlapping actors filtered by my alarm volume based on my player. I take the first entry and fire off the alert event. The alarm volume then does an unconditional getOverlappingActors and loops through everything to alert everything in it. This setup effectively only alerts guards in the correct areas and not all guards respective of their locations.

So if you are trying to do something with your hex actors in a particular location, I would use a volume for similar results.

If you wanted to do something with all hex actors in a random area, you could still use a volume. You would use getOverlappingActors on (whatever you call your custom volume) and then pick a random entry. Then again getOverlappingActors filtered by hex based on that.

Hmm… I’ll try getOverlappingActors.

My situation is different than yours. I have a 2D grid of hexes that I randomly place actors on. They don’t move so their positioning is the exact same as where I placed them.

Hello,
Your logic “get all actors” / “loop” / “get actor location” works fine. This is not your issue. Try to do it from a key event in level blueprint with a print string to see the results. Trouble can come from actors set in level (for exmple a mistake with meshes / blueprints) or something else you do in your blueprint, before or after this logic.

Hi Fen, in your experience, is there something in particular I should be looking for? It seems weird that anything would effect the location of an actor that never moves.

Maybe all of your hex objects are in the same place, but you’ve moved the components of those bp’s rather than the BP’s themselves?

I would post your whole graph. There isn’t enough displayed to know the complete story of what is going on here.