TargetLocation is already B-A

TargetLocation is already B-A bc it’s relative to A(our cube). There’s no need to solve for B. Additionally, in the example code bellow, Direction and DirectionTwo are equivalent.

		FVector Direction = TargetLocation.GetSafeNormal();  // is the same as 
		FVector DirectionTwo = (GetTransform().TransformPosition(TargetLocation) - GetActorLocation()).GetSafeNormal();

Here’s my debuger screen shot, so you can see the values of TargetLocation and BminusA are the same as well as Direction and DirectionTwo are the same.

Just for reference, here’s that chart

I’ve been really chewing on Vector Math for the past week, I’m glad it’s sticking. Thanks GDTV!

On a side note, I’ve never been able to evaluate an expression while debugging. For example, GetTransform().TransformPosition(TargetLocation) would generate an error in the evaluator. Is there a way to get it working properly?

2 Likes

The best way to deal with this is to log out the value. Honestly, It is usually easier to not rely on the debugger unless you get really stuck and UE_LOG is the best way to do this.

I think I’ve used the debugger about twice in the last 6 years of using UE. I see you’re using Rider, this helps as a debugger over studio but even with Rider I don’t think I’ve ever used debug.

As for the error, any expression would need to be a basic type. GetTransform is a complex type and so it probably cannot determine what it is.

1 Like

Privacy & Terms