Advertisement

How to calculate local velocity if you know it's world velocity and local rotation?

Started by February 11, 2016 05:31 PM
1 comment, last by Sidd 8 years, 7 months ago

I'm trying to simulate slip/tracking friction forces for my vehicle in UE4.

  • I have the component velocity in World Space
  • I have its local rotation

I used the following code to get the local directions for the my vehicle in World Space:


	// Getting direction realtive to the cuboid; Used in steering and friction calculations. 
	FRotator Rotation = VMesh->GetComponentRotation();
	FRotator Yawrotation(0.f, Rotation.Yaw, 0.f);
	ForwardDir = FRotationMatrix(Yawrotation).GetUnitAxis(EAxis::X);
	RightDir = FRotationMatrix(Yawrotation).GetUnitAxis(EAxis::Y);
	UpDir = FRotationMatrix(Yawrotation).GetUnitAxis(EAxis::Z);

I can't figure out how to get it's Local velocity. Can I use the above syntax to solve problem somehow?

https://docs.unrealengine.com/latest/INT/API/Runtime/Core/Math/FRotator/UnrotateVector/index.html


FVector localVelocity = Rotation.UnrotateVector(worldVelocity);
My current game project Platform RPG
Advertisement

Thank you so much! It works like a charm :) saved me hours of troubleshooting different methods

This topic is closed to new replies.

Advertisement