Improved jumping and added TODOs
This commit is contained in:
parent
9d911b058a
commit
51f44fc153
@ -33,6 +33,7 @@ Transform:
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 7008207193600475140}
|
||||
- {fileID: 3507368432553107122}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@ -194,3 +195,50 @@ MonoBehaviour:
|
||||
layerMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967048
|
||||
--- !u!1 &7353493454494059090
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3507368432553107122}
|
||||
- component: {fileID: 5720529389170152932}
|
||||
m_Layer: 6
|
||||
m_Name: PlayerInteractableTrigger
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &3507368432553107122
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7353493454494059090}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0.72, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1.5, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 7008207192594766311}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &5720529389170152932
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7353493454494059090}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 7000c8c0eb91b2d4cb9a0e3ee1b609a7, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
layerMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967040
|
||||
|
@ -132,7 +132,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 2
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -251,6 +251,63 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_LegacyBlendHint: 0
|
||||
m_ComponentOwner: {fileID: 1483260705}
|
||||
--- !u!1001 &353462435
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 2215831379607469555, guid: 166a1e67df866c64990d98902fcbeb71, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2215831379607469555, guid: 166a1e67df866c64990d98902fcbeb71, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 5.7088256
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2215831379607469555, guid: 166a1e67df866c64990d98902fcbeb71, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0.16614294
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2215831379607469555, guid: 166a1e67df866c64990d98902fcbeb71, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2215831379607469555, guid: 166a1e67df866c64990d98902fcbeb71, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2215831379607469555, guid: 166a1e67df866c64990d98902fcbeb71, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2215831379607469555, guid: 166a1e67df866c64990d98902fcbeb71, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2215831379607469555, guid: 166a1e67df866c64990d98902fcbeb71, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2215831379607469555, guid: 166a1e67df866c64990d98902fcbeb71, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2215831379607469555, guid: 166a1e67df866c64990d98902fcbeb71, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2215831379607469555, guid: 166a1e67df866c64990d98902fcbeb71, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6102515708334491356, guid: 166a1e67df866c64990d98902fcbeb71, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Basic Shooting Patrolling Enemy Variant
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 166a1e67df866c64990d98902fcbeb71, type: 3}
|
||||
--- !u!1001 &361923421
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -260,7 +317,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 1
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -397,7 +454,7 @@ Transform:
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 7
|
||||
m_RootOrder: 8
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!50 &1408086266
|
||||
Rigidbody2D:
|
||||
@ -477,7 +534,7 @@ Transform:
|
||||
- {fileID: 1514474963}
|
||||
- {fileID: 65152410}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 6
|
||||
m_RootOrder: 7
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1483260704
|
||||
GameObject:
|
||||
@ -789,7 +846,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 847968262667012088, guid: 9bff55120282d9e45a29d69eea4e6543, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 5
|
||||
value: 6
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 847968262667012088, guid: 9bff55120282d9e45a29d69eea4e6543, type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
@ -850,7 +907,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 847968262667012088, guid: 9bff55120282d9e45a29d69eea4e6543, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 3
|
||||
value: 4
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 847968262667012088, guid: 9bff55120282d9e45a29d69eea4e6543, type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
@ -915,7 +972,7 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7008207192594766311, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 4
|
||||
value: 5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7008207192594766311, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
|
@ -8,15 +8,19 @@ namespace Player
|
||||
{
|
||||
public class PlayerController : MonoBehaviour, IMovement, PlayerInput.IPlayerControlActions
|
||||
{
|
||||
private const float DefaultJumpForce = 9.81f;
|
||||
private const float DefaultMass = 80.0f;
|
||||
private const float DefaultJumpForce = 10.0f;
|
||||
private const float DefaultMass = 40.0f;
|
||||
private const float DefaultSpeed = 500.0f;
|
||||
private const float GravityScale = 1.0f;
|
||||
|
||||
private Input.PlayerInput _controls;
|
||||
private const float FallMultiplier = 3f;
|
||||
private const float LowJumpMultiplier = 3f;
|
||||
|
||||
private PlayerInput _controls;
|
||||
private Rigidbody2D _playerRigidbody2D;
|
||||
private SpriteRenderer _playerSpriteRenderer;
|
||||
|
||||
private CollisionChecker _playerGroundTrigger;
|
||||
private CollisionChecker _playerInteractableTrigger;
|
||||
|
||||
private bool _moveKeyPressed;
|
||||
private bool _jumpKeyPressed;
|
||||
@ -24,18 +28,17 @@ namespace Player
|
||||
private bool _isOnAir;
|
||||
|
||||
private float _xAxisValue;
|
||||
private PlayerInput.IPlayerControlActions _playerControlActionsImplementation;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_playerRigidbody2D = gameObject.GetComponent<Rigidbody2D>();
|
||||
_playerRigidbody2D = GetComponent<Rigidbody2D>();
|
||||
_playerSpriteRenderer = GetComponent<SpriteRenderer>();
|
||||
_playerGroundTrigger = GameObject.Find("PlayerGroundTrigger").GetComponent<CollisionChecker>();
|
||||
_playerSpriteRenderer = gameObject.GetComponent<SpriteRenderer>();
|
||||
_playerInteractableTrigger = GameObject.Find("PlayerInteractableTrigger").GetComponent<CollisionChecker>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_playerRigidbody2D.gravityScale = GravityScale;
|
||||
_playerRigidbody2D.mass = DefaultMass;
|
||||
BaseSpeed = DefaultSpeed;
|
||||
}
|
||||
@ -58,15 +61,33 @@ namespace Player
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
switch (_playerRigidbody2D.velocity.y)
|
||||
{
|
||||
case < 0:
|
||||
_playerRigidbody2D.velocity +=
|
||||
Vector2.up * (Physics2D.gravity.y * (FallMultiplier - 1) * Time.fixedDeltaTime);
|
||||
break;
|
||||
case > 0 when !_jumpKeyPressed:
|
||||
_playerRigidbody2D.velocity +=
|
||||
Vector2.up * (Physics2D.gravity.y * (LowJumpMultiplier - 1) * Time.fixedDeltaTime);
|
||||
break;
|
||||
}
|
||||
|
||||
if (_moveKeyPressed)
|
||||
Move(_xAxisValue);
|
||||
else
|
||||
_playerRigidbody2D.velocity = new Vector2(0.0f, _playerRigidbody2D.velocity.y);
|
||||
|
||||
//TODO prevent jumping while keep pressing the button
|
||||
if (_jumpKeyPressed && _playerGroundTrigger.IsCollided)
|
||||
Jump();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
//TODO calculate is on air based on wall and ground triggers
|
||||
}
|
||||
|
||||
// PAUSE METHODS
|
||||
|
||||
public bool IsPaused { get; private set; }
|
||||
@ -101,8 +122,9 @@ namespace Player
|
||||
|
||||
private void Jump()
|
||||
{
|
||||
_playerRigidbody2D.velocity = new Vector2(_playerRigidbody2D.velocity.x, 0);
|
||||
_playerRigidbody2D.AddForce(Vector2.up.normalized * DefaultJumpForce * DefaultMass, ForceMode2D.Impulse);
|
||||
//_playerRigidbody2D.velocity = new Vector2(_playerRigidbody2D.velocity.x, 0);
|
||||
//_playerRigidbody2D.AddForce(Vector2.up.normalized * DefaultJumpForce * DefaultMass, ForceMode2D.Impulse);
|
||||
_playerRigidbody2D.velocity = Vector2.up * DefaultJumpForce;
|
||||
}
|
||||
|
||||
private void Climb()
|
||||
@ -141,7 +163,8 @@ namespace Player
|
||||
|
||||
public void OnInteract(InputAction.CallbackContext context)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (_playerInteractableTrigger.IsCollided)
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ TagManager:
|
||||
- UI
|
||||
- Player
|
||||
- Enemy
|
||||
-
|
||||
- Interactables
|
||||
-
|
||||
-
|
||||
-
|
||||
|
@ -6,10 +6,10 @@ EditorUserSettings:
|
||||
serializedVersion: 4
|
||||
m_ConfigSettings:
|
||||
RecentlyUsedSceneGuid-0:
|
||||
value: 515250075c0c595e5f5a5e71122159444e4e4a2f7a7d7f602f284d66b4b76661
|
||||
value: 06550c57540350025c0b0f2747220a44174f4b73297070642b714465b0e6366e
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-1:
|
||||
value: 06550c57540350025c0b0f2747220a44174f4b73297070642b714465b0e6366e
|
||||
value: 515250075c0c595e5f5a5e71122159444e4e4a2f7a7d7f602f284d66b4b76661
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-2:
|
||||
value: 5002060403010b5f0f560e7a47260a444f4f1e2e2f2e27312f7f4536e0b6633d
|
||||
|
@ -25,7 +25,7 @@ MonoBehaviour:
|
||||
m_MinSize: {x: 300, y: 200}
|
||||
m_MaxSize: {x: 24288, y: 16192}
|
||||
vertical: 0
|
||||
controlID: 280
|
||||
controlID: 7914
|
||||
--- !u!114 &2
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
@ -142,7 +142,7 @@ MonoBehaviour:
|
||||
m_MinSize: {x: 100, y: 200}
|
||||
m_MaxSize: {x: 8096, y: 16192}
|
||||
vertical: 1
|
||||
controlID: 246
|
||||
controlID: 7877
|
||||
--- !u!114 &4
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
@ -162,8 +162,8 @@ MonoBehaviour:
|
||||
y: 0
|
||||
width: 304
|
||||
height: 381.6
|
||||
m_MinSize: {x: 201, y: 221}
|
||||
m_MaxSize: {x: 4001, y: 4021}
|
||||
m_MinSize: {x: 200, y: 200}
|
||||
m_MaxSize: {x: 4000, y: 4000}
|
||||
m_ActualView: {fileID: 5}
|
||||
m_Panes:
|
||||
- {fileID: 5}
|
||||
@ -202,7 +202,7 @@ MonoBehaviour:
|
||||
scrollPos: {x: 0, y: 0}
|
||||
m_SelectedIDs:
|
||||
m_LastClickedID: 0
|
||||
m_ExpandedIDs: 62f9ffff0cfbffff
|
||||
m_ExpandedIDs: 4adeffff8cdeffff7ce0ffffc2f2ffff28f3ffff62f9ffff0cfbffff
|
||||
m_RenameOverlay:
|
||||
m_UserAcceptedRename: 0
|
||||
m_Name:
|
||||
@ -333,8 +333,8 @@ MonoBehaviour:
|
||||
m_Icon: {fileID: 0}
|
||||
m_ResourceFile:
|
||||
m_AssetTreeState:
|
||||
scrollPos: {x: 0, y: 0}
|
||||
m_SelectedIDs: 10f9ffff
|
||||
scrollPos: {x: 0, y: 60}
|
||||
m_SelectedIDs: e4ddffff
|
||||
m_LastClickedID: 0
|
||||
m_ExpandedIDs: ffffffff00000000826300008463000086630000886300008a6300008c6300008e630000906300009263000094630000e0630000
|
||||
m_RenameOverlay:
|
||||
@ -361,8 +361,8 @@ MonoBehaviour:
|
||||
m_Icon: {fileID: 0}
|
||||
m_ResourceFile:
|
||||
m_ListAreaState:
|
||||
m_SelectedInstanceIDs: 10f9ffff
|
||||
m_LastClickedInstanceID: -1776
|
||||
m_SelectedInstanceIDs: e4ddffff
|
||||
m_LastClickedInstanceID: -8732
|
||||
m_HadKeyboardFocusLastEvent: 0
|
||||
m_ExpandedInstanceIDs: c6230000d03c0000
|
||||
m_RenameOverlay:
|
||||
@ -444,7 +444,7 @@ MonoBehaviour:
|
||||
m_MinSize: {x: 100, y: 200}
|
||||
m_MaxSize: {x: 8096, y: 16192}
|
||||
vertical: 1
|
||||
controlID: 281
|
||||
controlID: 7915
|
||||
--- !u!114 &10
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
@ -464,8 +464,8 @@ MonoBehaviour:
|
||||
y: 0
|
||||
width: 880
|
||||
height: 399.2
|
||||
m_MinSize: {x: 202, y: 221}
|
||||
m_MaxSize: {x: 4002, y: 4021}
|
||||
m_MinSize: {x: 200, y: 200}
|
||||
m_MaxSize: {x: 4000, y: 4000}
|
||||
m_ActualView: {fileID: 11}
|
||||
m_Panes:
|
||||
- {fileID: 11}
|
||||
@ -504,8 +504,8 @@ MonoBehaviour:
|
||||
floating: 0
|
||||
collapsed: 0
|
||||
displayed: 1
|
||||
snapOffset: {x: 0, y: 0}
|
||||
snapOffsetDelta: {x: -100, y: -25.600006}
|
||||
snapOffset: {x: -100, y: -25.600006}
|
||||
snapOffsetDelta: {x: 0, y: 0}
|
||||
snapCorner: 3
|
||||
id: Tool Settings
|
||||
index: 0
|
||||
@ -515,9 +515,9 @@ MonoBehaviour:
|
||||
floating: 0
|
||||
collapsed: 0
|
||||
displayed: 1
|
||||
snapOffset: {x: -141, y: 149}
|
||||
snapOffset: {x: -141, y: -204.6}
|
||||
snapOffsetDelta: {x: 0, y: 0}
|
||||
snapCorner: 1
|
||||
snapCorner: 3
|
||||
id: unity-grid-and-snap-toolbar
|
||||
index: 1
|
||||
layout: 1
|
||||
@ -526,7 +526,7 @@ MonoBehaviour:
|
||||
floating: 0
|
||||
collapsed: 0
|
||||
displayed: 1
|
||||
snapOffset: {x: 0, y: 0}
|
||||
snapOffset: {x: 0, y: 24.8}
|
||||
snapOffsetDelta: {x: 0, y: 0}
|
||||
snapCorner: 0
|
||||
id: unity-scene-view-toolbar
|
||||
@ -570,7 +570,7 @@ MonoBehaviour:
|
||||
floating: 0
|
||||
collapsed: 0
|
||||
displayed: 1
|
||||
snapOffset: {x: 0, y: 0}
|
||||
snapOffset: {x: 0, y: 24.8}
|
||||
snapOffsetDelta: {x: 0, y: 0}
|
||||
snapCorner: 0
|
||||
id: unity-transform-toolbar
|
||||
@ -718,9 +718,9 @@ MonoBehaviour:
|
||||
m_PlayAudio: 0
|
||||
m_AudioPlay: 0
|
||||
m_Position:
|
||||
m_Target: {x: 3.328073, y: 0.08547431, z: -0.07027102}
|
||||
m_Target: {x: -4.112955, y: -0.28965345, z: 0.056567457}
|
||||
speed: 2
|
||||
m_Value: {x: 3.328073, y: 0.08547431, z: -0.07027102}
|
||||
m_Value: {x: -4.112955, y: -0.28965345, z: 0.056567457}
|
||||
m_RenderMode: 0
|
||||
m_CameraMode:
|
||||
drawMode: 0
|
||||
@ -771,9 +771,9 @@ MonoBehaviour:
|
||||
speed: 2
|
||||
m_Value: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_Size:
|
||||
m_Target: 6.6387906
|
||||
m_Target: 0.7751675
|
||||
speed: 2
|
||||
m_Value: 6.6387906
|
||||
m_Value: 0.7751675
|
||||
m_Ortho:
|
||||
m_Target: 1
|
||||
speed: 2
|
||||
@ -884,7 +884,7 @@ MonoBehaviour:
|
||||
m_CachedPref: 160
|
||||
m_ControlHash: -371814159
|
||||
m_PrefName: Preview_InspectorPreview
|
||||
m_LastInspectedObjectInstanceID: -1776
|
||||
m_LastInspectedObjectInstanceID: -8732
|
||||
m_LastVerticalScrollValue: 0
|
||||
m_GlobalObjectId:
|
||||
m_InspectorMode: 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user