How to set character SideWays velocity?

I am trying to wrap this function in one line.

	FVector TempVelocity = TryGetPawnOwnerRef->GetVelocity();
	FRotator TempRotation = TryGetPawnOwnerRef->GetActorRotation();
	FVector BreakUnRotator = TempRotation.UnrotateVector(TempVelocity);
	SidewaysVelocity = BreakUnRotator.Y;

tried tihs but not compiling:
BreakUnRotator = FRotator::UnrotateVector(FVector(TryGetPawnOwnerRef->GetVelocity(), FRotator(TryGetPawnOwnerRef->GetActorRotation())));

I guess the problem is with FRotator::UnrotateVector - this is not a static method, which means you need to call it only from a specific object.
I think the correct wrapping is:

FVector BreakUnRotator = TryGetPawnOwnerRef->GetActorRotation().UnrotateVector(TryGetPawnOwnerRef->GetVelocity());

(I’ll think lack of compiler’s error log is just a forum bug)

1 Like