This commit is contained in:
Oscar 2024-10-19 15:47:54 +03:00
parent de20b3ba8a
commit 6b3ed6a2f4
4 changed files with 22 additions and 13 deletions

View File

@ -9192,7 +9192,7 @@ MeshCollider:
m_LayerOverridePriority: 0 m_LayerOverridePriority: 0
m_IsTrigger: 0 m_IsTrigger: 0
m_ProvidesContacts: 0 m_ProvidesContacts: 0
m_Enabled: 1 m_Enabled: 0
serializedVersion: 5 serializedVersion: 5
m_Convex: 0 m_Convex: 0
m_CookingOptions: 30 m_CookingOptions: 30
@ -9356,6 +9356,14 @@ PrefabInstance:
propertyPath: m_Name propertyPath: m_Name
value: SinglePlayer value: SinglePlayer
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8370227802790125322, guid: 22aace1332feb514b823ccbdd87e8439, type: 3}
propertyPath: runSpeed
value: 200
objectReference: {fileID: 0}
- target: {fileID: 8370227802790125322, guid: 22aace1332feb514b823ccbdd87e8439, type: 3}
propertyPath: walkSpeed
value: 200
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_RemovedGameObjects: [] m_RemovedGameObjects: []
m_AddedGameObjects: [] m_AddedGameObjects: []
@ -10624,7 +10632,7 @@ MeshCollider:
m_LayerOverridePriority: 0 m_LayerOverridePriority: 0
m_IsTrigger: 0 m_IsTrigger: 0
m_ProvidesContacts: 0 m_ProvidesContacts: 0
m_Enabled: 1 m_Enabled: 0
serializedVersion: 5 serializedVersion: 5
m_Convex: 0 m_Convex: 0
m_CookingOptions: 30 m_CookingOptions: 30

View File

@ -29,7 +29,7 @@ namespace Player
if (Cursor.lockState == CursorLockMode.Locked) if (Cursor.lockState == CursorLockMode.Locked)
{ {
transform.Rotate(Vector3.up * mouseX); transform.Rotate(Vector3.up * mouseX);
_camera.transform.localRotation = Quaternion.Euler(_xRotation, 0f, 0f); _cameraTransform.localRotation = Quaternion.Euler(_xRotation, 0f, 0f);
_cameraTransform.rotation = Quaternion.Euler(_xRotation, transform.eulerAngles.y, 0f); _cameraTransform.rotation = Quaternion.Euler(_xRotation, transform.eulerAngles.y, 0f);
_cameraTransform.position = targetCameraPosition.position; _cameraTransform.position = targetCameraPosition.position;
} }

View File

@ -1,14 +1,11 @@
using Mirror;
using Player.States;
using StateMachine;
using UnityEngine; using UnityEngine;
namespace Player namespace Player
{ {
public class Movement : MonoBehaviour public class Movement : MonoBehaviour
{ {
public float walkSpeed = 400f; public float walkSpeed;
public float runSpeed = 1200f; public float runSpeed;
public float jumpForce = 160f; public float jumpForce = 160f;
public float groundCheckRadius = 0.14f; public float groundCheckRadius = 0.14f;
public Transform groundCheck; public Transform groundCheck;
@ -24,7 +21,8 @@ namespace Player
{ {
playerRigidbody = GetComponent<Rigidbody>(); playerRigidbody = GetComponent<Rigidbody>();
} }
private Vector3 _velocity;
void Update() void Update()
{ {
isGrounded = Physics.CheckSphere(groundCheck.position, groundCheckRadius, groundLayer); isGrounded = Physics.CheckSphere(groundCheck.position, groundCheckRadius, groundLayer);
@ -34,14 +32,17 @@ namespace Player
playerRigidbody.AddForce(Vector3.up * jumpForce, ForceMode.Impulse); playerRigidbody.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
} }
Vector3 velocity = moveDirection * (walkSpeed * Time.deltaTime); _velocity = moveDirection * (walkSpeed * Time.fixedDeltaTime);
}
private void FixedUpdate()
{
if (Cursor.lockState == CursorLockMode.Locked) if (Cursor.lockState == CursorLockMode.Locked)
{ {
playerRigidbody.velocity = new Vector3(velocity.x, playerRigidbody.velocity.y, velocity.z); playerRigidbody.velocity = new Vector3(_velocity.x, playerRigidbody.velocity.y, _velocity.z);
} }
} }
void OnDrawGizmosSelected() void OnDrawGizmosSelected()
{ {
if (groundCheck != null) if (groundCheck != null)

View File

@ -103,7 +103,7 @@ PlayerSettings:
xboxEnableFitness: 0 xboxEnableFitness: 0
visibleInBackground: 1 visibleInBackground: 1
allowFullscreenSwitch: 1 allowFullscreenSwitch: 1
fullscreenMode: 0 fullscreenMode: 1
xboxSpeechDB: 0 xboxSpeechDB: 0
xboxEnableHeadOrientation: 0 xboxEnableHeadOrientation: 0
xboxEnableGuest: 0 xboxEnableGuest: 0