Announcement

Collapse
No announcement yet.

Error in order of the target points to be followed. How to set the order of elements in an array?

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

    Error in order of the target points to be followed. How to set the order of elements in an array?

    I have a project where it has 1 NPC and 3 target points:

    Click image for larger version

Name:	316.png
Views:	61
Size:	536.4 KB
ID:	1622881
    In the project I set the NPC to go to target point 1, then to 2, then to 3.

    Expected path:

    Click image for larger version

Name:	317.png
Views:	34
Size:	529.2 KB
ID:	1622886
    Path that is occurring:

    Click image for larger version

Name:	318.png
Views:	34
Size:	527.5 KB
ID:	1622885
    This problem did not happen out of nowhere, but first I will explain the creation of the target points.

    I created the first target point, added the components it needed, and then replicated it. Selecting the first target point and pressing CONTROL + W. I positioned the second target point, and then, again selecting the first target point, I again replicated it.

    The order of the path was as expected. I modified some code (none of the codes I modified related to the NPC or target points). After that I created a new target point (replicating it from the first target point) and then my problem started.

    The NPC was initially going to target point 3, to the 4, 1 and then 2.

    Even excluding target point 4, the order did not return to the expected (1, 2 and 3).

    I inserted a print after the loop that causes the NPC to move toward the target points, so I could figure out the order of the target points, and it is making sense with the order of the path that is taking place.

    Blueprint + Print:

    Click image for larger version

Name:	319.png
Views:	38
Size:	376.9 KB
ID:	1622884
    3 to 1 to 2.

    I created 2 more target points, and see how the order changes without any sense:

    Click image for larger version

Name:	320.png
Views:	35
Size:	209.5 KB
ID:	1622883

    4 to 5 to 1 to 2 to 3.

    I added another 1 target point to see if it meets a pattern:

    Click image for larger version

Name:	321.png
Views:	35
Size:	216.9 KB
ID:	1622882

    No sense at all.

    I'd like to know how to set the order of target points in the array.

    Sorry for bad English, I'm not a language speaker.

    I asked that same question on another site a few days ago (https://gamedev.stackexchange.com/qu...t-the-order-of), I researched order in an array and ways to set it, but I did not succeed.

    #2
    You can Make Array and / or Set Array Element:

    Click image for larger version  Name:	Capture.PNG Views:	1 Size:	23.5 KB ID:	1622980

    How do you gather the points atm,? If you're using a Get All node, it's not reliable for this.

    Another solution is to use a spline, they're always ordered. This seems related:

    https://forums.unrealengine.com/deve...-patrol-points

    Comment


      #3
      I get this array through function Get All Actor of Class.

      Blueprint:

      Click image for larger version

Name:	340.png
Views:	39
Size:	50.7 KB
ID:	1623340

      And then I use that array in a loop. With that I make a path/circuit.

      I looked at the link you sent, with some changes I can make the order I want.
      Last edited by B0n3c0 S1nf0r0s0; 05-23-2019, 08:10 PM.

      Comment

      Working...
      X