How to make something go away from my character (2d side scroller)

Hello,

I want make a certain actor (firefly) flee away from my character when I get close to it in a 2d side scroller (I exported it to ue5). It uses a timeline that goes from 0 time and 0 value to 1 second and 1 value. Then a lerp vector to a set world location for the firefly. Here is the blueprintue link:

What I’m trying to do is get the firefly to go in the exact opposite direction of the character. For example, if the character is directly beneath a firefly, then the firefly should only increase in z value. If the character is directly left, the firefly should only increase in x value. If its directly to the bottom left of a firefly, then the firefly should go relative to how much left and down it is. The y doesn’t apply in this scenario because it’s 2d. Also it shouldn’t rotate using atan2.

Thank you.

i think the unit vector is already normalized.

i think that by the way you’ve hooked this, your FF position is re-eavulated on every frame.
and because you change the position, it gets tangled.
you should store the direction unit vector in a local variable before calling the timeline.

Hi,

I know you’re probably really busy so thanks for responding.

If you don’t mind, what is a local variable? Does this mean I should put it in a vector and then from that vector connect it to the lerp?

Thanks.

Alright I solve it and if anyone ever has this problem this is the blueprintue link (make sure to stop any other timelines for the animated object):

Thanks nande.

1 Like

Sorry yeah i was busy.
A local variable is a somewhat basic concept

Im glad youve fixed it, good work!