#Smooth look at
1 messages · Page 1 of 1 (latest)
with lerp
class Bacon_RotateTowardsLerpComponentClass: ScriptComponentClass {}
class Bacon_RotateTowardsLerpComponent: ScriptComponent
{
IEntity m_target;
[Attribute("0.5", UIWidgets.Auto, "Lerp pct")]
float m_lerpPct;
override void OnPostInit(IEntity owner)
SetEventMask(owner, EntityEvent.INIT);
override void EOnInit(IEntity owner)
{
if (SCR_Global.IsEditMode())
return;
SetEventMask(owner, EntityEvent.FRAME);
owner.SetFlags(EntityFlags.ACTIVE, false);
};
override void EOnFrame(IEntity owner, float timeSlice)
{
m_target = SCR_PlayerController.GetLocalControlledEntity();
if (!m_target)
return;
vector myMatrix[4];
owner.GetWorldTransform(myMatrix);
vector lookAtMatrix[4];
SCR_Math3D.LookAt(owner.GetOrigin(), m_target.GetOrigin(), vector.Up, lookAtMatrix);
vector finalMatrix[4];
SCR_Global.LerpMatrix(myMatrix, lookAtMatrix, finalMatrix, m_lerpPct * timeSlice);
finalMatrix[3] = myMatrix[3]; // probably not necessary?
owner.SetWorldTransform(finalMatrix);
};
};
but this is only across one axis
Why is LerpMatrix in SCR_Global and not Math 
finalMatrix[3] = myMatrix[3]; This is needed
But it works on all axis
this works on all axis yes
class Bacon_RotateTowardsLerpComponentClass: ScriptComponentClass {}
class Bacon_RotateTowardsLerpComponent: ScriptComponent
{
IEntity m_target;
[Attribute("0.5", UIWidgets.Auto, "Lerp pct")]
float m_lerpPct;
override void OnPostInit(IEntity owner)
SetEventMask(owner, EntityEvent.INIT);
override void EOnInit(IEntity owner)
{
if (SCR_Global.IsEditMode())
return;
SetEventMask(owner, EntityEvent.FRAME);
owner.SetFlags(EntityFlags.ACTIVE, false);
};
override void EOnFrame(IEntity owner, float timeSlice)
{
m_target = SCR_PlayerController.GetLocalControlledEntity();
if (!m_target)
return;
vector directionMatrix[4];
vector desiredDirection = vector.Direction(owner.GetOrigin(), m_target.GetOrigin()).VectorToAngles();
Math3D.AnglesToMatrix(desiredDirection, directionMatrix);
vector myMatrix[4];
owner.GetWorldTransform(myMatrix);
vector finalMatrix[4];
SCR_Global.LerpMatrix(myMatrix, directionMatrix, finalMatrix, m_lerpPct * timeSlice);
finalMatrix[3] = myMatrix[3];
owner.SetWorldTransform(finalMatrix);
};
};
lookat will only do it across one I guess?
oh ok I didn't realize because my origin was at my feet I guess, so now you have 2 ways to do same thing 
To look at player eye pos:
ChimeraCharacter targetPlayer = ChimeraCharacter.Cast(m_Target);
SCR_Math3D.LookAt(GetOwner().GetOrigin(), targetPlayer.EyePosition(), vector.Up, lookAtMatrix);
nice, though the camera is actually somewhere around the nose I think

