Announcement

Collapse
No announcement yet.

Check for actor at specific location

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Check for actor at specific location

    I'm creating a game that uses a grid-based tile system. Each tile contains a reference to it's neighbours. I'm trying to create a construction script that automatically searches for neighbours to save manually linking them, but I can't figure out how to get an actor at a specific location. Any tips?

    #2
    I may be on my way to solving this. I created a function that uses a line trace to check in a specified relative location. The problem is when I return the Tile_C object, and attempt to connect it to the SET node for the appropriate variable, I get the error object 'SKEL_Tile_C' is not compatible with object 'Tile_C'. But my function has a single output of type Tile_C, so I'm not sure what's happening here?

    Click image for larger version

Name:	getTile_blueprint.jpg
Views:	1
Size:	16.8 KB
ID:	1049993

    EDIT: I'm not sure why my screenshot is being auto-resized to an unreadably small image.

    Here's an imgur upload:

    Last edited by Boon; 04-08-2014, 04:56 AM.

    Comment


      #3
      Another update:

      I added a "Cast to Tile" node after the function return to force the reference to the correct type (though I'm still not sure why the function isn't returning the expected, defined return type). This casts the SKEL_Tile_C to Tile_C and seems to work.

      However, I've got another problem in that the function isn't executing as expected when called multiple times in the same graph.

      I've set my Single Line Trace to draw a debug line showing the ray cast, because I wasn't getting the expected results. I call the function in my construction script (also tested by attaching to a Begin Play event in the event graph) four times, once each for +X, -X, +Y, -Y. However inconsistently, not all function calls are executing. This error is visible both in the draw debug for the line trace, and the lack of expected results.

      Attached Files

      Comment


        #4
        Okay I seem to have solved the problem, by using a Sequence node rather than chaining all of the function calls together.

        Comment


          #5
          I would still like to understand why my function is returning something of type SKEL_Tile_C (I don't know what this class is) instead of the specified type Tile_C.

          Comment


            #6
            I hope someone can answer you because your method seems pretty interesting(coming from a guy who is also working with tile maps ).

            Does your line trace work for instanced meshes that have been procedurally generated? I ask because it seems like the maps I generate procedurally all act as 1 single object once generated.
            Map Generator 1.0
            Map Generator 2.0
            Map Generator 3.0

            Comment


              #7
              I'm not sure I'm afraid. Currently I'm hand-placing tiles, but I do intend to refactor to procedural / run-time generated tile maps in the future. I'll be sure to update this post when I do.

              Comment


                #8
                how about this, create your tile blueprint, make a big enough volumn that could overlap with neighbour tiles.
                Create a function or interface or custom events to call during BeginPlay in level or game mode, which use getAllActorsByClass and loop through them.
                Where the function would use the onOverlap to return a array of actors/components, and you can save it to a objectArray variable.

                When you have procedural generation later down the road, you won't have to worry about hooking up as well. Just generate and place tiles, and existing gamemode/level logic would still be good.
                Unreal Engine 4 Game Framework diagram for relation of all major base object types
                Unreal Engine 4 Input Event diagram, scroll down to section Input Processing Procedural
                Resident Evil Classic Camera
                RPCs official document, Must Read
                Everything you should know about replication

                Comment


                  #9
                  Sounds worth exploring.

                  Comment


                    #10
                    The "SKEL_..." thing is definitely a bug. "SKEL_" is the prefix we throw on an intermediate class that should be kept internal. If you haven't already, could you please post this issue on AnswerHub with repro steps (and maybe the asset files that are giving you the issue).

                    Thanks and sorry for the confusion!

                    Comment

                    Working...
                    X