Add local offset to vector instead of actor location

Hello !

The node AddActorLocalOffset is great to move an actor by giving it a vector offset that applies to the actor referential instead of the world’s one.

However, I sometimes want to compute the location of something (like for example knowing the location of the point 2 meters ahead of the actor). I don’t want to move the actor there, I just want to know the location. What I would need is an AddTransformLocalOffset node or something similar. Building it is not too complex I guess (using the actor forward vector), but I was wondering if it already existed somewhere and I just didn’t find it. It seems to me to be something that has a lot of use cases and is already implemented within the engine as part of AddActorLocalOffset.

I’m not sure if I understand.
You don’t want to move the actor, yet you want to add to its offset?
If you just want to know the location of a thing that is 2 meters away you could simply perform a line trace.

Yes, I want to be able to add a local offset on the location (which depends on the rotation) without moving the actor. For example, a use case could be that I want to spawn an actor 10 meters ahead of another actor. I can spawn the actor and then use AddActorLocalOffset but that may generate unwanted collision events & others. Using an AddTransformLocalOffset to calculate the position before spawning the actor seems much better, but such method doesn’t seem to exist.

Not sure if this is going to be useful at all. How about adding a scene component to the character and then just placing it where you want it in relation to the character. I checked just now and it does print out the right world transform. I remember doing this somewhere before like that and with good results. But I do believe there is a better (pro way) to do it.

Ah, okay I see. There are no one-node solutions for this as far as my knowledge goes, but it’s certainly possible without too much of an effort. DonBusso has a simple way to do it.

And line tracing is also still an option (although a bit more sophisticated).
Not too long ago Unreal uploaded a video of some devs: They wanted a random spawn point at a valid location.

https://youtu.be/V_YiDqXU-Gs?t=1557

(time stamp included)

They are basically line tracing downwards to determine a spawn point. You could do something similar just with different conditions for a successful trace.
If you cast downwards an obstacle would be not at floor level, so you could repeat the line trace if the hit result doesn’t happen at the floor level.

You could also use the up and forward vector to line trace around the player character. And a valid spawn location would then be a certain distance away from any hit result, but also not too close to the player, the exact numbers are up to you.

Just some ideas, have no example but should work.

I’m fairly new and learning as I go so I tend to keep things simple. I will be sure to watch that video tomorrow in full. Learning more about tracing is on my list. Thank you for sharing @Aphermion

Another alternative is using a socket set with the desired relative location to the skeletal mesh of the actor. Quite similar to your scene component workaround. I guess I’ll just end up making my own AddTransformLocalOffset method if I encounter this issue again later to have a cleaner and faster way to deal with this problem.

Thanks to both of you for your suggestions ! :smiley:

Hey, you can use GetForwardVector like you said and then multiply it by 200 (200cm = 2m), then GetActorLocation (of your character) + ForwardVector*200. Hope this help

1 Like

That solution implies that your character is not on sloped ground (no angle on height) or it will give a relative position on a plane parallel to the sloped ground (which may or may not be desired). But for most use cases I guess that is the easiest and cleanest way, thanks :smiley:

Use the location and forward vector or look direction of the Camera you are using or controlling, makes it easy to do traces and other checks when you use the camera.