Cleanup
This commit is contained in:
parent
ce73d9be30
commit
926aded95d
|
@ -814,13 +814,6 @@ AnimationClip:
|
||||||
floatParameter: 0
|
floatParameter: 0
|
||||||
intParameter: 0
|
intParameter: 0
|
||||||
messageOptions: 0
|
messageOptions: 0
|
||||||
- time: 0.25
|
|
||||||
functionName: AttackHitEvent
|
|
||||||
data:
|
|
||||||
objectReferenceParameter: {fileID: 0}
|
|
||||||
floatParameter: 0
|
|
||||||
intParameter: 0
|
|
||||||
messageOptions: 0
|
|
||||||
- time: 0.41666666
|
- time: 0.41666666
|
||||||
functionName: AttackHitEvent
|
functionName: AttackHitEvent
|
||||||
data:
|
data:
|
||||||
|
@ -828,10 +821,3 @@ AnimationClip:
|
||||||
floatParameter: 0
|
floatParameter: 0
|
||||||
intParameter: 0
|
intParameter: 0
|
||||||
messageOptions: 0
|
messageOptions: 0
|
||||||
- time: 0.5833333
|
|
||||||
functionName: AttackHitEvent
|
|
||||||
data:
|
|
||||||
objectReferenceParameter: {fileID: 0}
|
|
||||||
floatParameter: 0
|
|
||||||
intParameter: 0
|
|
||||||
messageOptions: 0
|
|
||||||
|
|
|
@ -18,4 +18,4 @@ public class EnemyAttack : MonoBehaviour
|
||||||
Debug.Log($"{transform.name} Hits {_target.transform.name}");
|
Debug.Log($"{transform.name} Hits {_target.transform.name}");
|
||||||
_target.GetComponent<IDamageable>().ModifyHealth(-_damage);
|
_target.GetComponent<IDamageable>().ModifyHealth(-_damage);
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -48,40 +48,11 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 01ef216392c8f33409f2efcd91f4e510, type: 3}
|
m_Script: {fileID: 11500000, guid: 01ef216392c8f33409f2efcd91f4e510, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
fireAction:
|
_fpCamera: {fileID: 0}
|
||||||
m_Name: Fire
|
_muzzleFlash: {fileID: 0}
|
||||||
m_Type: 0
|
_bulletImpact: {fileID: 0}
|
||||||
m_ExpectedControlType:
|
_range: 100
|
||||||
m_Id: 1ed57d50-dc55-4571-aecd-b32a46cca345
|
_weaponDamage: 25
|
||||||
m_Processors:
|
|
||||||
m_Interactions:
|
|
||||||
m_SingletonActionBindings:
|
|
||||||
- m_Name:
|
|
||||||
m_Id: 9820ce96-b93a-4117-a273-5fff0a8424d5
|
|
||||||
m_Path: <Mouse>/leftButton
|
|
||||||
m_Interactions:
|
|
||||||
m_Processors:
|
|
||||||
m_Groups:
|
|
||||||
m_Action: Fire
|
|
||||||
m_Flags: 0
|
|
||||||
m_Flags: 0
|
|
||||||
reloadAction:
|
|
||||||
m_Name: Reload
|
|
||||||
m_Type: 0
|
|
||||||
m_ExpectedControlType:
|
|
||||||
m_Id: b2fa540f-5a3f-4fb7-b40b-672ea6bc4308
|
|
||||||
m_Processors:
|
|
||||||
m_Interactions:
|
|
||||||
m_SingletonActionBindings:
|
|
||||||
- m_Name:
|
|
||||||
m_Id: 58f8c3e7-8210-4dc2-8eae-d4494d6fdbcc
|
|
||||||
m_Path: <Keyboard>/#(R)
|
|
||||||
m_Interactions:
|
|
||||||
m_Processors:
|
|
||||||
m_Groups:
|
|
||||||
m_Action: Reload
|
|
||||||
m_Flags: 0
|
|
||||||
m_Flags: 0
|
|
||||||
--- !u!1 &4135013735270702863
|
--- !u!1 &4135013735270702863
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -331,7 +302,7 @@ MonoBehaviour:
|
||||||
jump: 0
|
jump: 0
|
||||||
sprint: 0
|
sprint: 0
|
||||||
analogMovement: 0
|
analogMovement: 0
|
||||||
cursorLocked: 1
|
cursorLocked: 0
|
||||||
cursorInputForLook: 1
|
cursorInputForLook: 1
|
||||||
--- !u!114 &8616685848737228376
|
--- !u!114 &8616685848737228376
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
|
|
|
@ -132,13 +132,13 @@ namespace StarterAssets
|
||||||
private void CameraRotation()
|
private void CameraRotation()
|
||||||
{
|
{
|
||||||
// if there is an input
|
// if there is an input
|
||||||
if (_input.look.sqrMagnitude >= _threshold)
|
if (_input._look.sqrMagnitude >= _threshold)
|
||||||
{
|
{
|
||||||
//Don't multiply mouse input by Time.deltaTime
|
//Don't multiply mouse input by Time.deltaTime
|
||||||
float deltaTimeMultiplier = IsCurrentDeviceMouse ? 1.0f : Time.deltaTime;
|
float deltaTimeMultiplier = IsCurrentDeviceMouse ? 1.0f : Time.deltaTime;
|
||||||
|
|
||||||
_cinemachineTargetPitch += _input.look.y * RotationSpeed * deltaTimeMultiplier;
|
_cinemachineTargetPitch += _input._look.y * RotationSpeed * deltaTimeMultiplier;
|
||||||
_rotationVelocity = _input.look.x * RotationSpeed * deltaTimeMultiplier;
|
_rotationVelocity = _input._look.x * RotationSpeed * deltaTimeMultiplier;
|
||||||
|
|
||||||
// clamp our pitch rotation
|
// clamp our pitch rotation
|
||||||
_cinemachineTargetPitch = ClampAngle(_cinemachineTargetPitch, BottomClamp, TopClamp);
|
_cinemachineTargetPitch = ClampAngle(_cinemachineTargetPitch, BottomClamp, TopClamp);
|
||||||
|
@ -154,19 +154,19 @@ namespace StarterAssets
|
||||||
private void Move()
|
private void Move()
|
||||||
{
|
{
|
||||||
// set target speed based on move speed, sprint speed and if sprint is pressed
|
// set target speed based on move speed, sprint speed and if sprint is pressed
|
||||||
float targetSpeed = _input.sprint ? SprintSpeed : MoveSpeed;
|
float targetSpeed = _input._sprint ? SprintSpeed : MoveSpeed;
|
||||||
|
|
||||||
// a simplistic acceleration and deceleration designed to be easy to remove, replace, or iterate upon
|
// a simplistic acceleration and deceleration designed to be easy to remove, replace, or iterate upon
|
||||||
|
|
||||||
// note: Vector2's == operator uses approximation so is not floating point error prone, and is cheaper than magnitude
|
// note: Vector2's == operator uses approximation so is not floating point error prone, and is cheaper than magnitude
|
||||||
// if there is no input, set the target speed to 0
|
// if there is no input, set the target speed to 0
|
||||||
if (_input.move == Vector2.zero) targetSpeed = 0.0f;
|
if (_input._move == Vector2.zero) targetSpeed = 0.0f;
|
||||||
|
|
||||||
// a reference to the players current horizontal velocity
|
// a reference to the players current horizontal velocity
|
||||||
float currentHorizontalSpeed = new Vector3(_controller.velocity.x, 0.0f, _controller.velocity.z).magnitude;
|
float currentHorizontalSpeed = new Vector3(_controller.velocity.x, 0.0f, _controller.velocity.z).magnitude;
|
||||||
|
|
||||||
float speedOffset = 0.1f;
|
float speedOffset = 0.1f;
|
||||||
float inputMagnitude = _input.analogMovement ? _input.move.magnitude : 1f;
|
float inputMagnitude = _input._analogMovement ? _input._move.magnitude : 1f;
|
||||||
|
|
||||||
// accelerate or decelerate to target speed
|
// accelerate or decelerate to target speed
|
||||||
if (currentHorizontalSpeed < targetSpeed - speedOffset || currentHorizontalSpeed > targetSpeed + speedOffset)
|
if (currentHorizontalSpeed < targetSpeed - speedOffset || currentHorizontalSpeed > targetSpeed + speedOffset)
|
||||||
|
@ -184,14 +184,14 @@ namespace StarterAssets
|
||||||
}
|
}
|
||||||
|
|
||||||
// normalise input direction
|
// normalise input direction
|
||||||
Vector3 inputDirection = new Vector3(_input.move.x, 0.0f, _input.move.y).normalized;
|
Vector3 inputDirection = new Vector3(_input._move.x, 0.0f, _input._move.y).normalized;
|
||||||
|
|
||||||
// note: Vector2's != operator uses approximation so is not floating point error prone, and is cheaper than magnitude
|
// note: Vector2's != operator uses approximation so is not floating point error prone, and is cheaper than magnitude
|
||||||
// if there is a move input rotate player when the player is moving
|
// if there is a move input rotate player when the player is moving
|
||||||
if (_input.move != Vector2.zero)
|
if (_input._move != Vector2.zero)
|
||||||
{
|
{
|
||||||
// move
|
// move
|
||||||
inputDirection = transform.right * _input.move.x + transform.forward * _input.move.y;
|
inputDirection = transform.right * _input._move.x + transform.forward * _input._move.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// move the player
|
// move the player
|
||||||
|
@ -212,7 +212,7 @@ namespace StarterAssets
|
||||||
}
|
}
|
||||||
|
|
||||||
// Jump
|
// Jump
|
||||||
if (_input.jump && _jumpTimeoutDelta <= 0.0f)
|
if (_input._jump && _jumpTimeoutDelta <= 0.0f)
|
||||||
{
|
{
|
||||||
// the square root of H * -2 * G = how much velocity needed to reach desired height
|
// the square root of H * -2 * G = how much velocity needed to reach desired height
|
||||||
_verticalVelocity = Mathf.Sqrt(JumpHeight * -2f * Gravity);
|
_verticalVelocity = Mathf.Sqrt(JumpHeight * -2f * Gravity);
|
||||||
|
@ -236,7 +236,7 @@ namespace StarterAssets
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we are not grounded, do not jump
|
// if we are not grounded, do not jump
|
||||||
_input.jump = false;
|
_input._jump = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply gravity over time if under terminal (multiply by delta time twice to linearly speed up over time)
|
// apply gravity over time if under terminal (multiply by delta time twice to linearly speed up over time)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "StarterAssets",
|
"name": "MainPlayerInputs",
|
||||||
"maps": [
|
"maps": [
|
||||||
{
|
{
|
||||||
"name": "Player",
|
"name": "Player",
|
||||||
|
@ -58,6 +58,15 @@
|
||||||
"processors": "",
|
"processors": "",
|
||||||
"interactions": "",
|
"interactions": "",
|
||||||
"initialStateCheck": false
|
"initialStateCheck": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Menu",
|
||||||
|
"type": "Button",
|
||||||
|
"id": "4a5c59b4-fdfb-4dfb-bfc1-1bd6c4a121c5",
|
||||||
|
"expectedControlType": "Button",
|
||||||
|
"processors": "",
|
||||||
|
"interactions": "",
|
||||||
|
"initialStateCheck": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bindings": [
|
"bindings": [
|
||||||
|
@ -302,6 +311,85 @@
|
||||||
"action": "Reload",
|
"action": "Reload",
|
||||||
"isComposite": false,
|
"isComposite": false,
|
||||||
"isPartOfComposite": false
|
"isPartOfComposite": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"id": "2d98121e-31da-4f67-8ba8-29af21310b0e",
|
||||||
|
"path": "<Keyboard>/escape",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "",
|
||||||
|
"action": "Menu",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "UI",
|
||||||
|
"id": "baa56f6d-d4c0-4362-9dfd-8c705d923a27",
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"name": "Point",
|
||||||
|
"type": "Value",
|
||||||
|
"id": "d69fb5b5-7d08-4dbc-aeff-8ddc6d53b1e6",
|
||||||
|
"expectedControlType": "Vector2",
|
||||||
|
"processors": "",
|
||||||
|
"interactions": "",
|
||||||
|
"initialStateCheck": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "LeftClick",
|
||||||
|
"type": "Button",
|
||||||
|
"id": "4abf5888-18af-42f1-8413-e41292e4263a",
|
||||||
|
"expectedControlType": "Button",
|
||||||
|
"processors": "",
|
||||||
|
"interactions": "",
|
||||||
|
"initialStateCheck": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "RightClick",
|
||||||
|
"type": "Button",
|
||||||
|
"id": "f3efb458-0934-4a2e-9b28-ca1f96bfb964",
|
||||||
|
"expectedControlType": "Button",
|
||||||
|
"processors": "",
|
||||||
|
"interactions": "",
|
||||||
|
"initialStateCheck": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"bindings": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"id": "07dfed60-4a97-4d73-8f98-6824430eacd7",
|
||||||
|
"path": "<Mouse>/position",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "",
|
||||||
|
"action": "Point",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"id": "242e9c4e-9e5b-4e10-8b8d-f54a91c731d8",
|
||||||
|
"path": "<Mouse>/leftButton",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "",
|
||||||
|
"action": "LeftClick",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"id": "1d18148c-458c-4452-a4bf-f81fec56bcfb",
|
||||||
|
"path": "<Mouse>/rightButton",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "",
|
||||||
|
"action": "RightClick",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,76 +5,87 @@ using UnityEngine.InputSystem;
|
||||||
|
|
||||||
namespace StarterAssets
|
namespace StarterAssets
|
||||||
{
|
{
|
||||||
public class StarterAssetsInputs : MonoBehaviour
|
public class StarterAssetsInputs : MonoBehaviour
|
||||||
{
|
{
|
||||||
[Header("Character Input Values")]
|
[Header("Character Input Values")]
|
||||||
public Vector2 move;
|
public Vector2 _move;
|
||||||
public Vector2 look;
|
public Vector2 _look;
|
||||||
public bool jump;
|
public bool _jump;
|
||||||
public bool sprint;
|
public bool _sprint;
|
||||||
|
|
||||||
[Header("Movement Settings")]
|
[Header("Movement Settings")]
|
||||||
public bool analogMovement;
|
public bool _analogMovement;
|
||||||
|
|
||||||
[Header("Mouse Cursor Settings")]
|
[Header("Mouse Cursor Settings")]
|
||||||
public bool cursorLocked = true;
|
public bool _cursorLocked = true;
|
||||||
public bool cursorInputForLook = true;
|
public bool _cursorInputForLook = true;
|
||||||
|
|
||||||
#if ENABLE_INPUT_SYSTEM && STARTER_ASSETS_PACKAGES_CHECKED
|
#if ENABLE_INPUT_SYSTEM && STARTER_ASSETS_PACKAGES_CHECKED
|
||||||
public void OnMove(InputValue value)
|
public void OnMove(InputValue value)
|
||||||
{
|
{
|
||||||
MoveInput(value.Get<Vector2>());
|
MoveInput(value.Get<Vector2>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnLook(InputValue value)
|
public void OnLook(InputValue value)
|
||||||
{
|
{
|
||||||
if(cursorInputForLook)
|
if (_cursorInputForLook)
|
||||||
{
|
{
|
||||||
LookInput(value.Get<Vector2>());
|
LookInput(value.Get<Vector2>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnJump(InputValue value)
|
public void OnJump(InputValue value)
|
||||||
{
|
{
|
||||||
JumpInput(value.isPressed);
|
JumpInput(value.isPressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnSprint(InputValue value)
|
public void OnSprint(InputValue value)
|
||||||
{
|
{
|
||||||
SprintInput(value.isPressed);
|
SprintInput(value.isPressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnMenu()
|
||||||
|
{
|
||||||
|
_cursorLocked = false;
|
||||||
|
SetCursorState();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
_cursorLocked = true;
|
||||||
|
SetCursorState();
|
||||||
|
}
|
||||||
|
|
||||||
public void MoveInput(Vector2 newMoveDirection)
|
public void MoveInput(Vector2 newMoveDirection)
|
||||||
{
|
{
|
||||||
move = newMoveDirection;
|
_move = newMoveDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LookInput(Vector2 newLookDirection)
|
public void LookInput(Vector2 newLookDirection)
|
||||||
{
|
{
|
||||||
look = newLookDirection;
|
_look = newLookDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void JumpInput(bool newJumpState)
|
public void JumpInput(bool newJumpState)
|
||||||
{
|
{
|
||||||
jump = newJumpState;
|
_jump = newJumpState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SprintInput(bool newSprintState)
|
public void SprintInput(bool newSprintState)
|
||||||
{
|
{
|
||||||
sprint = newSprintState;
|
_sprint = newSprintState;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnApplicationFocus(bool hasFocus)
|
|
||||||
{
|
|
||||||
SetCursorState(cursorLocked);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetCursorState(bool newState)
|
private void OnApplicationFocus(bool hasFocus)
|
||||||
{
|
{
|
||||||
Cursor.lockState = newState ? CursorLockMode.Locked : CursorLockMode.None;
|
_cursorLocked = true;
|
||||||
}
|
SetCursorState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetCursorState()
|
||||||
|
{
|
||||||
|
Cursor.lockState = _cursorLocked ? CursorLockMode.Locked : CursorLockMode.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -48,8 +48,9 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 01ef216392c8f33409f2efcd91f4e510, type: 3}
|
m_Script: {fileID: 11500000, guid: 01ef216392c8f33409f2efcd91f4e510, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_FpCamera: {fileID: 0}
|
_fpCamera: {fileID: 0}
|
||||||
_MuzzleFlash: {fileID: 0}
|
_muzzleFlash: {fileID: 6070271853189258210}
|
||||||
|
_bulletImpact: {fileID: 252487699782519274, guid: 82851982cb47c134a8403ffcb052b9d2, type: 3}
|
||||||
_range: 100
|
_range: 100
|
||||||
_weaponDamage: 25
|
_weaponDamage: 25
|
||||||
--- !u!1 &160878
|
--- !u!1 &160878
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
EditorBuildSettings:
|
EditorBuildSettings:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Scenes: []
|
m_Scenes:
|
||||||
|
- enabled: 1
|
||||||
|
path: Assets/Scenes/Sandbox.unity
|
||||||
|
guid: 9fc0d4010bbf28b4594072e72b8655ab
|
||||||
m_configObjects:
|
m_configObjects:
|
||||||
com.unity.input.settings: {fileID: 11400000, guid: 9e7be553448fa2546aea5752021cbcf7, type: 2}
|
com.unity.input.settings: {fileID: 11400000, guid: 9e7be553448fa2546aea5752021cbcf7, type: 2}
|
||||||
|
|
Loading…
Reference in New Issue