[Blueprint] Paper2D enemy patrol / Actor relative location issue

I’ve been trying to set up enemy character automatic movement with the same logic used in this “Intelligent lift” tutorial: Paper2D: Creating an Intelligent Lift | 09 | v4.4 Tutorial Series | Unreal Engine - YouTube

While lift works perfectly in my prototype, I’ve run into some unexpected issues with enemy character’s location.

As shown on the editor screenshot, the enemy should walk from Start Point to End Point (both are vector variables in Enemy blueprint with coordinates that, supposedly, are relative to the character). Instead, my character is teleported into another location and moves along these coordinates relative to the world (as shown in the gameplay screenshot).

More interesting is the fact that enemy movement blueprint is absolutely the same as lift movement blueprint. And lift is working, while enemy patrol doesn’t. The only difference is that lift is based on Actor blueprint and Enemy is based on PaperCharacter blueprint.

The question is: what am I missing, why this patrol logic doesn’t work as it should?

P.S.: I am using UE 4.10.1. The game is made from scratch without using 2D sidescroller blueprint.

P.P.S.: I understand, that I could store initial enemy location in a variable, then break vectors, then create new ones with Y and Z same as initial and X same as StartPoint X and EndPoint X and move between these two vectors. But this method doesn’t seem very elegant, especially in comparison with working lift :slight_smile:

The main difference between the lift and your character is that you use “Self” instead of the sprite.

I am not actually sure why it even allows you to do that. There is no relative position for the root component / your actor. It is the root. Moving something relatively to itself doesn’t work and something weird is bound to happen. As far as I can see it you have two options.

  1. You replace “Self” with the reference to your sprite.
  2. On even construct you get the world location of your two points and store those. Lerping between two points in world space and not relative space.

I see, so in case of the lift I move component relatively to root, while root remains in place, and in this case I’m trying to move root relatively to itself, which makes game go crazy.

Moving sprite actually did the trick, it moves exactly as it should, but in that case I’ll also have to move every other component. So I guess going with storing locations will be the best option.

Thank you very much!

Just as heads up. The components follow a strict hierarchy as well.

If you drag every component that should be moved above the sprite (so it becomes the new parent) every child of the sprite will move as well.