Merge pull request #269 from SHADE-DP/PlayerController

Change playercontroller to fixed dt and change starting scene
This commit is contained in:
XiaoQiDigipen 2022-11-24 01:41:01 +08:00 committed by GitHub
commit 83a4577081
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

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

View File

@ -315,13 +315,13 @@ public class PlayerController : Script
{ {
Quaternion currentRotation = tranform.LocalRotation; Quaternion currentRotation = tranform.LocalRotation;
Quaternion targetRotation = Quaternion.LookRotation(new Vector3(axisMove.x, 0.0f, axisMove.y), new Vector3(0.0f, 1.0f, 0.0f)); 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) else if (camArm && tranform && isAiming)
{ {
Quaternion currentRotation = tranform.LocalRotation; Quaternion currentRotation = tranform.LocalRotation;
Quaternion targetRotation = Quaternion.Euler(0.0f, SHADE.Math.DegreesToRadians(camArm.Yaw + 180.0f), 0.0f); 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) else if (currentState == RaccoonStates.FALLING)
{ {
float prevYVel = v.y; 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; float nextYVel = (prevYVel + newYVel) * 0.5f;
v.y = nextYVel; v.y = nextYVel;
} }
else else
{ {
float prevYVel = v.y; 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; float nextYVel = (prevYVel + newYVel) * 0.5f;
v.y = nextYVel; v.y = nextYVel;
} }