mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-29 12:52:07 +01:00
Fixed Neck
Fixed the Player Controller Prefab
This commit is contained in:
@@ -32,8 +32,8 @@ Transform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 2458562619286483438}
|
||||
- {fileID: 6272346181657429396}
|
||||
- {fileID: 6272346182417644039}
|
||||
- {fileID: 223626088105882255}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@@ -49,7 +49,7 @@ CharacterController:
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Height: 2
|
||||
m_Radius: 0.5
|
||||
m_Radius: 0.3
|
||||
m_SlopeLimit: 45
|
||||
m_StepOffset: 0.1
|
||||
m_SkinWidth: 0.08
|
||||
@@ -68,10 +68,16 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
playerCamera: {fileID: 6272346181657429396}
|
||||
playerNeck: {fileID: 223626088105882255}
|
||||
mouseSensitivity: 4
|
||||
neckStartAngle: 0
|
||||
maxCameraAngle: 90
|
||||
minCameraAngle: -90
|
||||
neckLength: 0.2
|
||||
mouseSmoothTime: 0
|
||||
lockCursor: 1
|
||||
walkSpeed: 6
|
||||
sprintSpeed: 10
|
||||
moveSmoothTime: 0.05
|
||||
gravity: -13
|
||||
jumpHeight: 1
|
||||
@@ -138,13 +144,13 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6272346181657429393}
|
||||
m_LocalRotation: {x: -0, y: -0.67557263, z: -0, w: 0.7372934}
|
||||
m_LocalPosition: {x: 0, y: 2, z: 0}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0.3, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 6272346181302961296}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: -84.997, z: 0}
|
||||
m_Father: {fileID: 223626088105882255}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!20 &6272346181657429395
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -224,6 +230,37 @@ Transform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 6272346181302961296}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &7697277603114630017
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 223626088105882255}
|
||||
m_Layer: 0
|
||||
m_Name: Neck
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &223626088105882255
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7697277603114630017}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1.8, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 6272346181657429396}
|
||||
m_Father: {fileID: 6272346181302961296}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &8690889598169456425
|
||||
@@ -274,7 +311,7 @@ MeshRenderer:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8690889598169456425}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
@@ -318,7 +355,7 @@ CapsuleCollider:
|
||||
m_GameObject: {fileID: 8690889598169456425}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_Radius: 0.5
|
||||
m_Height: 2
|
||||
m_Direction: 1
|
||||
|
||||
@@ -1069,6 +1069,63 @@ MeshCollider:
|
||||
m_Convex: 0
|
||||
m_CookingOptions: 30
|
||||
m_Mesh: {fileID: 8552134717624371188, guid: 823e8b39d52b71b4eb5a91dbc8d6d59e, type: 3}
|
||||
--- !u!1001 &1880657102
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 6272346181302961293, guid: 2935eead9a075fd489d6a6dc273a5999, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Player
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6272346181302961296, guid: 2935eead9a075fd489d6a6dc273a5999, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 6
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6272346181302961296, guid: 2935eead9a075fd489d6a6dc273a5999, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6272346181302961296, guid: 2935eead9a075fd489d6a6dc273a5999, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 2.15
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6272346181302961296, guid: 2935eead9a075fd489d6a6dc273a5999, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6272346181302961296, guid: 2935eead9a075fd489d6a6dc273a5999, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6272346181302961296, guid: 2935eead9a075fd489d6a6dc273a5999, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6272346181302961296, guid: 2935eead9a075fd489d6a6dc273a5999, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6272346181302961296, guid: 2935eead9a075fd489d6a6dc273a5999, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6272346181302961296, guid: 2935eead9a075fd489d6a6dc273a5999, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6272346181302961296, guid: 2935eead9a075fd489d6a6dc273a5999, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6272346181302961296, guid: 2935eead9a075fd489d6a6dc273a5999, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 2935eead9a075fd489d6a6dc273a5999, type: 3}
|
||||
--- !u!1 &1960893053
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -12,9 +12,9 @@ public class PlayerController : MonoBehaviour
|
||||
[SerializeField] private Transform playerNeck = null;
|
||||
[SerializeField] private float mouseSensitivity = 4.0f;
|
||||
|
||||
[SerializeField] private float maxCameraAngle = -90f;
|
||||
[SerializeField] private float neckStartAngle = 0f;
|
||||
[SerializeField] private float minCameraAngle = 90f;
|
||||
[SerializeField] private float maxCameraAngle = 90f;
|
||||
[SerializeField] private float minCameraAngle = -90f;
|
||||
|
||||
[SerializeField] private float neckLength = 0.2f;
|
||||
[SerializeField] [Range(0.0f, 0.5f)] private float mouseSmoothTime = 0.001f;
|
||||
@@ -22,6 +22,7 @@ public class PlayerController : MonoBehaviour
|
||||
|
||||
[Header("Movement")]
|
||||
[SerializeField] private float walkSpeed = 6.0f;
|
||||
[SerializeField] private float sprintSpeed = 10.0f;
|
||||
[SerializeField][Range(0.0f, 0.5f)] private float moveSmoothTime = 0.05f;
|
||||
[SerializeField] float gravity = -13.0f;
|
||||
[SerializeField] private float jumpHeight;
|
||||
@@ -32,9 +33,7 @@ public class PlayerController : MonoBehaviour
|
||||
[SerializeField] private LayerMask groundMask;
|
||||
|
||||
public bool isGrounded;
|
||||
private float fullPitch = 0f;
|
||||
private float cameraPitch = 0f;
|
||||
private float neckPitch = 0f;
|
||||
private float viewPitch = 0f;
|
||||
private float velocityY = 0.0f;
|
||||
private CharacterController controller;
|
||||
|
||||
@@ -53,6 +52,10 @@ public class PlayerController : MonoBehaviour
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
Cursor.visible = false;
|
||||
}
|
||||
|
||||
//Position the camera at the height of the neck (set by the neckLength)
|
||||
playerCamera.position = playerNeck.position;
|
||||
playerCamera.position += playerNeck.up * neckLength;
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
@@ -70,30 +73,19 @@ public class PlayerController : MonoBehaviour
|
||||
Vector2 targetMouseDelta = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")); //Get the axis of the mouse
|
||||
|
||||
currentMouseDelta = Vector2.SmoothDamp(currentMouseDelta, targetMouseDelta, ref currentMouseDeltaVelocity, mouseSmoothTime);
|
||||
fullPitch -= currentMouseDelta.y * mouseSensitivity;
|
||||
fullPitch = Mathf.Clamp(fullPitch,-maxCameraAngle,-minCameraAngle);
|
||||
//cameraPitch = Mathf.Clamp(fullPitch, -90, 45);
|
||||
|
||||
//neckPitch = Mathf.Clamp(fullPitch, 45, 90);
|
||||
Debug.Log("fullPitch: " + fullPitch);
|
||||
viewPitch -= currentMouseDelta.y * mouseSensitivity;
|
||||
|
||||
if (fullPitch >= neckStartAngle) {
|
||||
playerNeck.localEulerAngles = Vector3.right * (fullPitch - neckStartAngle);
|
||||
|
||||
viewPitch = Mathf.Clamp(viewPitch,-maxCameraAngle,-minCameraAngle);
|
||||
|
||||
if (viewPitch >= neckStartAngle)
|
||||
{
|
||||
playerNeck.localEulerAngles = Vector3.right * (viewPitch - neckStartAngle);
|
||||
}
|
||||
else {
|
||||
playerCamera.localEulerAngles = Vector3.right * fullPitch;
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
playerCamera.localEulerAngles = Vector3.right * viewPitch;
|
||||
}
|
||||
playerCamera.position = playerNeck.position;
|
||||
playerCamera.position += playerNeck.up * neckLength;
|
||||
/*
|
||||
playerNeck.localEulerAngles = Vector3.right * neckPitch;
|
||||
playerCamera.localEulerAngles = Vector3.right * cameraPitch;
|
||||
playerCamera.position = playerNeck.position;
|
||||
playerCamera.position += playerNeck.up * neckLength;*/
|
||||
//playerCamera.RotateAround(playerNeck.position, Vector3.right, cameraPitch* Mathf.Deg2Rad - playerCamera.transform.rotation.x);
|
||||
|
||||
transform.Rotate(Vector3.up * currentMouseDelta.x * mouseSensitivity); //Rotate the hole player if looked sideways (Rotates the player left and right)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user