Scene Changes and bug fixes #431

Merged
glencelow merged 9 commits from PlayerController into main 2023-03-20 17:42:41 +08:00
4 changed files with 53 additions and 12 deletions
Showing only changes of commit 77907841b1 - Show all commits

View File

@ -7548,7 +7548,7 @@
Enabled: true
respawnPoint: 65732
currentState: 0
maxMoveVel: 3
walkMaxMoveVel: 2.5
moveForce: 50
sprintMultiplier: 1.5
rotationFactorPerFrame: 5
@ -7556,6 +7556,9 @@
maxJumpTime: 1
fallMultipler: 2
jumpPadMultiplayer: 1.20000005
dropDuration: 0.5
jumpPadFallMultipler: 0.75
jumpPadMaxMoveVel: 1
lightMultiper: 0.899999976
mediumMultiper: 0.699999988
heavyMultiper: 0.5

View File

@ -3098,7 +3098,7 @@
Enabled: true
respawnPoint: 239
currentState: 0
maxMoveVel: 3
walkMaxMoveVel: 2.5
moveForce: 50
sprintMultiplier: 1.5
rotationFactorPerFrame: 5
@ -3106,6 +3106,9 @@
maxJumpTime: 1
fallMultipler: 2
jumpPadMultiplayer: 1.20000005
dropDuration: 0.5
jumpPadFallMultipler: 0.75
jumpPadMaxMoveVel: 1
lightMultiper: 0.899999976
mediumMultiper: 0.699999988
heavyMultiper: 0.5

View File

@ -12046,14 +12046,17 @@
Enabled: true
respawnPoint: 66065
currentState: 0
maxMoveVel: 3
walkMaxMoveVel: 2.5
moveForce: 50
sprintMultiplier: 1.5
rotationFactorPerFrame: 5
maxJumpHeight: 3
maxJumpTime: 1
fallMultipler: 2
jumpPadMultiplayer: 1.5
jumpPadMultiplayer: 1.39999998
dropDuration: 0.5
jumpPadFallMultipler: 0.75
jumpPadMaxMoveVel: 1
lightMultiper: 0.899999976
mediumMultiper: 0.699999988
heavyMultiper: 0.5

View File

@ -37,7 +37,7 @@ public class PlayerController : Script
//Movement variables============================================================
[Tooltip("Max vel for walking")]
public float maxMoveVel = 3.0f;
public float walkMaxMoveVel = 3.0f;
[Tooltip("how much force is apply for walking")]
public float moveForce = 50.0f;
[Tooltip("increase the moveForce and maxMoveVel by its amt")]
@ -69,6 +69,13 @@ public class PlayerController : Script
[Tooltip("multiply height on Jump Pad ")]
public float jumpPadMultiplayer = 2.0f;
private bool jumpPadDrop = false;
private float dropTimer = 0.0f;
public float dropDuration = 0.5f;
public float jumpPadFallMultipler = 0.75f;
public float jumpPadMaxMoveVel = 1.0f;
private float currMoveVel = 0.0f;
//ItemMultipler==================================================================
[Tooltip("How light item will affect player jump")]
public float lightMultiper = 0.75f;
@ -191,7 +198,17 @@ public class PlayerController : Script
pat.prevTargetOffSet = camArm.TargetOffset;
}
if (jumpPadDrop && currentState == RaccoonStates.FALLING)
{
dropTimer += Time.DeltaTimeF;
if (dropTimer > dropDuration)
{
jumpPadDrop = false;
dropTimer = 0.0f;
currMoveVel = walkMaxMoveVel;
}
}
GotCaught();
Rotation();
@ -283,10 +300,15 @@ public class PlayerController : Script
{
Vector3 velNor = rb.LinearVelocity;
velNor.y = 0.0f;
if (velNor.GetMagnitude() > maxMoveVel)
if (jumpPadDrop)
currMoveVel = jumpPadMaxMoveVel;
else
currMoveVel = walkMaxMoveVel;
if (velNor.GetMagnitude() > currMoveVel)
{
velNor.Normalise();
velNor *= maxMoveVel;
velNor *= currMoveVel;
rb.LinearVelocity = new Vector3(velNor.x, rb.LinearVelocity.y, velNor.z);
}
}
@ -308,8 +330,8 @@ public class PlayerController : Script
oldForce = moveForce;
moveForce *= sprintMultiplier;
maxOldVel = maxMoveVel;
maxMoveVel *= sprintMultiplier;
maxOldVel = walkMaxMoveVel;
walkMaxMoveVel *= sprintMultiplier;
}
}
@ -329,7 +351,7 @@ public class PlayerController : Script
}
sprintIncreaseOnce = false;
moveForce = oldForce;
maxMoveVel = maxOldVel;
walkMaxMoveVel = maxOldVel;
}
}
@ -360,6 +382,7 @@ public class PlayerController : Script
{
v.y *= jumpPadMultiplayer;
landedOnJumpPad = false;
jumpPadDrop = true;
}
rb.LinearVelocity = v;
}
@ -403,6 +426,9 @@ public class PlayerController : Script
if (currentState == RaccoonStates.FALLING)
{
currentState = RaccoonStates.LANDED;
jumpPadDrop = false;
dropTimer = 0.0f;
currMoveVel = walkMaxMoveVel;
playLandedAnimation = true;
if (stateMachine && !stateMachine.IsState(typeof(PlayerLandState)))
stateMachine.SetState(typeof(PlayerLandState));
@ -418,7 +444,13 @@ public class PlayerController : Script
else if (currentState == RaccoonStates.FALLING)
{
float prevYVel = v.y;
float newYVel = v.y + (gravity * fallMultipler * (float)Time.FixedDeltaTime);
float newYVel = 0;
if (jumpPadDrop)
newYVel = v.y + (gravity * jumpPadFallMultipler * (float)Time.FixedDeltaTime);
else
newYVel = v.y + (gravity * fallMultipler * (float)Time.FixedDeltaTime);
float nextYVel = (prevYVel + newYVel) * 0.5f;
v.y = nextYVel;
}