Change playercontroller to fixed dt and change starting scene #269

Merged
glencelow merged 2 commits from PlayerController into main 2022-11-24 01:41:01 +08:00
2 changed files with 5 additions and 5 deletions
Showing only changes of commit 5ee8403e80 - Show all commits

View File

@ -1,4 +1,4 @@
Start in Fullscreen: false
Starting Scene ID: 94246101
Starting Scene ID: 97158628
Window Size: {x: 1920, y: 1080}
Window Title: SHADE Engine

View File

@ -315,13 +315,13 @@ public class PlayerController : Script
{
Quaternion currentRotation = tranform.LocalRotation;
Quaternion targetRotation = Quaternion.LookRotation(new Vector3(axisMove.x, 0.0f, axisMove.y), new Vector3(0.0f, 1.0f, 0.0f));
tranform.LocalRotation = Quaternion.Slerp(currentRotation, targetRotation, rotationFactorPerFrame * (float)Time.DeltaTime);
tranform.LocalRotation = Quaternion.Slerp(currentRotation, targetRotation, rotationFactorPerFrame * (float)Time.FixedDeltaTime);
}
else if (camArm && tranform && isAiming)
{
Quaternion currentRotation = tranform.LocalRotation;
Quaternion targetRotation = Quaternion.Euler(0.0f, SHADE.Math.DegreesToRadians(camArm.Yaw + 180.0f), 0.0f);
tranform.LocalRotation = Quaternion.Slerp(currentRotation, targetRotation, rotationFactorPerFrame * (float)Time.DeltaTime);
tranform.LocalRotation = Quaternion.Slerp(currentRotation, targetRotation, rotationFactorPerFrame * (float)Time.FixedDeltaTime);
}
}
@ -346,14 +346,14 @@ public class PlayerController : Script
else if (currentState == RaccoonStates.FALLING)
{
float prevYVel = v.y;
float newYVel = v.y + (gravity * fallMultipler * (float)Time.DeltaTime);
float newYVel = v.y + (gravity * fallMultipler * (float)Time.FixedDeltaTime);
float nextYVel = (prevYVel + newYVel) * 0.5f;
v.y = nextYVel;
}
else
{
float prevYVel = v.y;
float newYVel = v.y + (gravity * (float)Time.DeltaTime);
float newYVel = v.y + (gravity * (float)Time.FixedDeltaTime);
float nextYVel = (prevYVel + newYVel) * 0.5f;
v.y = nextYVel;
}