mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-29 20:52:10 +01:00
I Think i Fixed Everyting
This commit is contained in:
@@ -8,7 +8,7 @@ using Mirror;
|
||||
|
||||
public class PlayerController : NetworkBehaviour
|
||||
{
|
||||
[SerializeField] private AimDownSights ADSContoller;
|
||||
[SerializeField] private ProcedualAnimationController procedualAnimationController;
|
||||
[Header("Movement")]
|
||||
[SerializeField] private float walkSpeed = 6.0f;
|
||||
[SerializeField] private float sprintSpeed = 10.0f;
|
||||
@@ -36,7 +36,8 @@ public class PlayerController : NetworkBehaviour
|
||||
|
||||
private Vector3 currentDir = Vector3.zero;
|
||||
private Vector3 currentDirVelocity = Vector3.zero;
|
||||
private Vector3 velocity = Vector3.zero;
|
||||
public Vector3 velocity = Vector3.zero;
|
||||
private Vector3 refVelocity = Vector3.zero;
|
||||
|
||||
|
||||
private void Start()
|
||||
@@ -65,8 +66,8 @@ public class PlayerController : NetworkBehaviour
|
||||
|
||||
public bool isMoving()
|
||||
{
|
||||
if (velocity.x == 0 && velocity.y == 0 && velocity.z == 0) return true;
|
||||
else return false;
|
||||
if (velocity.x == 0 && velocity.y == 0 && velocity.z == 0) return false;
|
||||
else return true;
|
||||
}
|
||||
|
||||
private void CheckGoundAngle()
|
||||
@@ -101,16 +102,18 @@ public class PlayerController : NetworkBehaviour
|
||||
{
|
||||
|
||||
|
||||
if (Input.GetAxisRaw("Sprint") > 0 && isGrounded && !ADSContoller.isAiming)
|
||||
{
|
||||
if (Input.GetAxisRaw("Sprint") > 0 && isGrounded && !procedualAnimationController.isAiming)
|
||||
{
|
||||
movementSpeed = sprintSpeed;
|
||||
isSprinting = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ADSContoller.isAiming) movementSpeed = aimWalkSpeed;
|
||||
|
||||
if(procedualAnimationController.isAiming) movementSpeed = aimWalkSpeed;
|
||||
else movementSpeed = walkSpeed;
|
||||
isSprinting = false;
|
||||
|
||||
}
|
||||
|
||||
//Grounded
|
||||
@@ -133,6 +136,7 @@ public class PlayerController : NetworkBehaviour
|
||||
}
|
||||
|
||||
inputDirection = new Vector3(Input.GetAxisRaw("Horizontal"),0, Input.GetAxisRaw("Vertical")); //Get Inputs
|
||||
|
||||
inputDirection.Normalize(); //Damit schr<68>g laufen nicht schneller ist
|
||||
|
||||
if (isGrounded)
|
||||
@@ -145,11 +149,8 @@ public class PlayerController : NetworkBehaviour
|
||||
currentDir = moveDirection;
|
||||
}
|
||||
|
||||
velocity = currentDir * movementSpeed + new Vector3(0, velocityY, 0);
|
||||
|
||||
|
||||
velocity = Vector3.SmoothDamp(velocity, currentDir * movementSpeed + new Vector3(0, velocityY, 0),ref refVelocity,0.01f);
|
||||
controller.Move(velocity * Time.deltaTime);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user