Lengthening or Continuing a Trace / Vector

Hi guys

Basically what I’m trying to do is make a vector that continues (using a trace right now for visualization) after hitting the player. Right now it has a static starting point for testing.

The purpose is to have the enemies track the player location and then move in a straight line outside the playable area. I managed to make them do this with a projectile type movement but that created some issues when hitting them due to losing the movement capabilities afterwards.

I know that it shouldn’t be to hard to make through some vector maths but it’s never been my strongest suit and I’ve been trying make it work for a while now :expressionless:

For refence sake right now it’s 2D and will probably stay that way.

Hi Sekoran,

Instead of continuing the same line, try spawning a new trace from the hit actor or hit location to a specified amount in the same direction as the original line. You can get the information you are looking for without having to do additional work for it.

Thanks for the answer

Trying to implement what you said but my problem now is having the trace continue in the same direction as the original one. Been digging around a bit more here on the hub as well and found these two other threads that kind of related to this (although in a somewhat different manner).

The version posted:

(End = start point + TraceLength x Direction)
And Direction is world space direction, and is the rotator made into a vector.

Somewhat worked but had issues with offset rotations depending on where the actor and player is on the screen (probably a faulty implementation by me though).

My main thought is to get the length of the trace (start/end) to create a new vector from it and afterwards rotate it to face in the same direction the enemy is facing (i.e through the player). Problem with this is that it ends up offset in a positive or completely different direction instead of behind the player.

Kind of stumped right now :confused:

Okay

So I decided to circumvent my problem a bit by looking back at it. Instead of trying to lengthen my trace (which would have been nice) I just made a trace in the direction my enemy is looking in that went further than my character and collides with an invisible wall outside the playable area.

I then use a simple BB/BT to move the actor to the desired position and voilà, worked (nearly) instantly. One thing I don’t quite understand with the forward vector is how inaccurate it is when short, but increasing the length multiplier value fixed it.

And the results + blueprints.