Is there a way to save the path i took?

hey, is there a way where i memorize the path i took, then by pressing a key save that path and transfer that path to a NPC so it follows the path i took and does exactly the same i did? Would appreciate any tips!

I can’t think of any easy ways to do this.

I think you could perhaps make your character spawn an invisible placeholder actor every second and then have the NPC run to location down an array from get all actors of class. But, it seems like there should be an easier way to do this than that.

I thought about maybe setting a spline while playing and then save that and give it to the NPC after i pressed a button but even if that would work i would’ve no idea how.

Oh i also just had the idea of using a tick event on the character blueprint and loop that event. Make the event check the character location and save a point to an array. Not sure if that would work.

All of these sound roughly as viable as each other. Just pick one to try out. :slight_smile:

…I’m not sure if UE allows runtime creation of spline points though. That one might be out.

I imagine the easiest way is to:

  • add properties for “LastSavedPosition” and “LastSavedHeading”
  • Add an array of Vector called ThePath

Run something in Tick that checks:
Have I moved more than 100 units, or turned more than 30 degrees, since the last saved place-and-heading?
If so, snapshot my current position to a struct, and append it to ThePath. Update LastSavedPosition and LastSavedHeading.

When pressing the “save the path” button, copy this array into the NPC. Make the NPC follow each waypoint in turn. This is most easily done by doing “MoveToPosition” using AI walking, and in the “on near position” pop off the position and “move to position” the next point in the path.

Thanks for your answer first of all. What i now am trying to do is to use the event tick with a delay, then i get the location of myself and insert the vector into an array. With that array i’m using the “Set Spline Points” function. It’s not working yet but i’ll try to do it my way. If i can’t get it to work at all i’ll try your idea.