Re: Quaternion from two points

#2
You can use the Quat::CreateRotationVDir() function.

Here is an example:

Code: Select all

Vec3 direction = (destination - origin).GetNormalized();

Quat finalRotation = Quat::CreateRotationVDir(direction);

//Depends on what you need but you could also use Quat::CreateNlerp() or similar to lerp the rotation
finalRotation = Quat::CreateNlerp(m_pEntity->GetWorldRotation(), finalRotation, 0.25f);

m_pEntity->SetPosRotScale(m_pEntity->GetWorldPos(), finalRotation, Vec3(1.f));
My Youtube Channel

Re: Quaternion from two points

#3
You can use the Quat::CreateRotationVDir() function.

Here is an example:

Code: Select all

Vec3 direction = (destination - origin).GetNormalized();

Quat finalRotation = Quat::CreateRotationVDir(direction);

//Depends on what you need but you could also use Quat::CreateNlerp() or similar to lerp the rotation
finalRotation = Quat::CreateNlerp(m_pEntity->GetWorldRotation(), finalRotation, 0.25f);

m_pEntity->SetPosRotScale(m_pEntity->GetWorldPos(), finalRotation, Vec3(1.f));
Thanks! Will try this out.

Who is online

Users browsing this forum: No registered users and 2 guests