aboutsummaryrefslogtreecommitdiffstats
path: root/Assets
diff options
context:
space:
mode:
authorNeil Kollack <nkollack@gmail.com>2022-04-17 19:15:56 -0500
committerNeil Kollack <nkollack@gmail.com>2022-04-17 19:15:56 -0500
commit4e6d25526f52dd2db06bc58f04c6e51272b049ea (patch)
tree7dffa644f219cc6eb4149f42233f16ecae28c7d8 /Assets
parent729c9e5b461966381af7c2464712fb8a23a6f4aa (diff)
fix: improve slope collision
Diffstat (limited to 'Assets')
-rw-r--r--Assets/Prefabs/Player.prefab71
-rw-r--r--Assets/Scenes/Jungle.unity74
-rw-r--r--Assets/Scripts/Actors/Actor.cs16
3 files changed, 105 insertions, 56 deletions
diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab
index 48cd8d1..b9d27ee 100644
--- a/Assets/Prefabs/Player.prefab
+++ b/Assets/Prefabs/Player.prefab
@@ -24,7 +24,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2776418409611166768}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
- m_LocalPosition: {x: 0, y: -1.5, z: 0}
+ m_LocalPosition: {x: -0.5, y: -1.5, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@@ -75,8 +75,8 @@ GameObject:
- component: {fileID: 2776418409999972330}
- component: {fileID: 2776418409999972326}
- component: {fileID: 2776418409999972325}
- - component: {fileID: 2577645590865157111}
- component: {fileID: 6634715301000360765}
+ - component: {fileID: 2871775561671245473}
- component: {fileID: 2776418409999972327}
- component: {fileID: 6691474245549666832}
- component: {fileID: 1811562883}
@@ -101,6 +101,7 @@ Transform:
m_Children:
- {fileID: 2776418409611166769}
- {fileID: 2776418409812533937}
+ - {fileID: 5336306221325820075}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -227,22 +228,6 @@ Rigidbody2D:
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 4
---- !u!70 &2577645590865157111
-CapsuleCollider2D:
- m_ObjectHideFlags: 0
- m_CorrespondingSourceObject: {fileID: 0}
- m_PrefabInstance: {fileID: 0}
- m_PrefabAsset: {fileID: 0}
- m_GameObject: {fileID: 2776418409999972310}
- m_Enabled: 1
- m_Density: 1
- m_Material: {fileID: 0}
- m_IsTrigger: 0
- m_UsedByEffector: 0
- m_UsedByComposite: 0
- m_Offset: {x: 0, y: 0}
- m_Size: {x: 1.2666667, y: 3}
- m_Direction: 0
--- !u!60 &6634715301000360765
PolygonCollider2D:
m_ObjectHideFlags: 0
@@ -298,6 +283,22 @@ PolygonCollider2D:
- {x: 0.59626955, y: 0.12525597}
- {x: 0.4297921, y: 0.6684373}
- {x: 0.2295515, y: 0.8399347}
+--- !u!70 &2871775561671245473
+CapsuleCollider2D:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 2776418409999972310}
+ m_Enabled: 1
+ m_Density: 1
+ m_Material: {fileID: 0}
+ m_IsTrigger: 0
+ m_UsedByEffector: 0
+ m_UsedByComposite: 0
+ m_Offset: {x: 0, y: -0.081344366}
+ m_Size: {x: 1.125, y: 2.9126887}
+ m_Direction: 0
--- !u!114 &2776418409999972327
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -317,7 +318,8 @@ MonoBehaviour:
maxJumps: 1
jumpForce: 1200
damage: 0
- groundCheckPoint: {fileID: 2776418409611166769}
+ groundCheckPoint1: {fileID: 2776418409611166769}
+ groundCheckPoint2: {fileID: 5336306221325820075}
invulnTime: 2
stats:
maxHealth: 0
@@ -363,3 +365,34 @@ MonoBehaviour:
- {fileID: 0}
heartSprite: {fileID: 21300000, guid: 454fb9103270323479e05b92e4ecf4d0, type: 3}
health: 0
+--- !u!1 &8892911079024906682
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 5336306221325820075}
+ m_Layer: 8
+ m_Name: GroundPoint (1)
+ m_TagString: Untagged
+ m_Icon: {fileID: 7866945982896999795, guid: 0000000000000000d000000000000000, type: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!4 &5336306221325820075
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 8892911079024906682}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 0.5, y: -1.5, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_ConstrainProportionsScale: 0
+ m_Children: []
+ m_Father: {fileID: 2776418409999972307}
+ m_RootOrder: 2
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
diff --git a/Assets/Scenes/Jungle.unity b/Assets/Scenes/Jungle.unity
index 91d739a..5afd3a7 100644
--- a/Assets/Scenes/Jungle.unity
+++ b/Assets/Scenes/Jungle.unity
@@ -13109,7 +13109,8 @@ MonoBehaviour:
maxJumps: 1
jumpForce: 500
damage: 0
- groundCheckPoint: {fileID: 819884911}
+ groundCheckPoint1: {fileID: 0}
+ groundCheckPoint2: {fileID: 0}
invulnTime: 0
stats:
maxHealth: 0
@@ -13118,7 +13119,6 @@ MonoBehaviour:
jumpForce: 0
damage: 0
health: 0
- invuln: 0
--- !u!50 &1238560270
Rigidbody2D:
serializedVersion: 4
@@ -15753,8 +15753,8 @@ GameObject:
- component: {fileID: 1742717048}
- component: {fileID: 1742717047}
- component: {fileID: 1742717046}
- - component: {fileID: 1742717051}
- - component: {fileID: 1742717052}
+ - component: {fileID: 1742717053}
+ - component: {fileID: 1742717054}
m_Layer: 6
m_Name: Collidable
m_TagString: Untagged
@@ -304728,8 +304728,8 @@ Tilemap:
e31: 0
e32: 0
e33: 1
---- !u!68 &1742717051
-EdgeCollider2D:
+--- !u!60 &1742717053
+PolygonCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
@@ -304742,16 +304742,23 @@ EdgeCollider2D:
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
- m_EdgeRadius: 0
+ m_SpriteTilingProperty:
+ border: {x: 0, y: 0, z: 0, w: 0}
+ pivot: {x: 0, y: 0}
+ oldSize: {x: 0, y: 0}
+ newSize: {x: 0, y: 0}
+ adaptiveTilingThreshold: 0
+ drawMode: 0
+ adaptiveTiling: 0
+ m_AutoTiling: 0
m_Points:
- - {x: 125.99989, y: 4.9998217}
- - {x: 174.0004, y: -19.000204}
- m_AdjacentStartPoint: {x: 0, y: 0}
- m_AdjacentEndPoint: {x: 0, y: 0}
- m_UseAdjacentStartPoint: 0
- m_UseAdjacentEndPoint: 0
---- !u!68 &1742717052
-EdgeCollider2D:
+ m_Paths:
+ - - {x: 125.992676, y: 4.9948897}
+ - {x: 125.98835, y: 3.9997568}
+ - {x: 174.07405, y: -20.075758}
+ - {x: 174.26929, y: -19.123075}
+--- !u!60 &1742717054
+PolygonCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
@@ -304764,14 +304771,21 @@ EdgeCollider2D:
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
- m_EdgeRadius: 0
+ m_SpriteTilingProperty:
+ border: {x: 0, y: 0, z: 0, w: 0}
+ pivot: {x: 0, y: 0}
+ oldSize: {x: 0, y: 0}
+ newSize: {x: 0, y: 0}
+ adaptiveTilingThreshold: 0
+ drawMode: 0
+ adaptiveTiling: 0
+ m_AutoTiling: 0
m_Points:
- - {x: 298.9999, y: 15.999956}
- - {x: 383.0763, y: -26.038239}
- m_AdjacentStartPoint: {x: 0, y: 0}
- m_AdjacentEndPoint: {x: 0, y: 0}
- m_UseAdjacentStartPoint: 0
- m_UseAdjacentEndPoint: 0
+ m_Paths:
+ - - {x: 298.999, y: 15.997521}
+ - {x: 298.99966, y: 15.000196}
+ - {x: 383.0634, y: -26.97408}
+ - {x: 383.25873, y: -26.127563}
--- !u!1 &1787799414
GameObject:
m_ObjectHideFlags: 0
@@ -326753,10 +326767,6 @@ PrefabInstance:
propertyPath: m_Name
value: Player
objectReference: {fileID: 0}
- - target: {fileID: 2776418409999972326, guid: b2169aaeb9a0e4542b1fb9d601bcc4b2, type: 3}
- propertyPath: m_UIInputModule
- value:
- objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: b2169aaeb9a0e4542b1fb9d601bcc4b2, type: 3}
--- !u!114 &7434619225285215647
@@ -326778,7 +326788,8 @@ MonoBehaviour:
maxJumps: 1
jumpForce: 500
damage: 0
- groundCheckPoint: {fileID: 2602158012877245240}
+ groundCheckPoint1: {fileID: 0}
+ groundCheckPoint2: {fileID: 0}
invulnTime: 0
stats:
maxHealth: 0
@@ -326787,7 +326798,6 @@ MonoBehaviour:
jumpForce: 0
damage: 0
health: 0
- invuln: 0
--- !u!114 &7434619227103773699
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -326807,7 +326817,8 @@ MonoBehaviour:
maxJumps: 1
jumpForce: 500
damage: 0
- groundCheckPoint: {fileID: 2602158014812719780}
+ groundCheckPoint1: {fileID: 0}
+ groundCheckPoint2: {fileID: 0}
invulnTime: 0
stats:
maxHealth: 0
@@ -326816,7 +326827,6 @@ MonoBehaviour:
jumpForce: 0
damage: 0
health: 0
- invuln: 0
--- !u!50 &7876354948194620163
Rigidbody2D:
serializedVersion: 4
@@ -327310,7 +327320,8 @@ MonoBehaviour:
maxJumps: 1
jumpForce: 500
damage: 0
- groundCheckPoint: {fileID: 8919320861079350896}
+ groundCheckPoint1: {fileID: 0}
+ groundCheckPoint2: {fileID: 0}
invulnTime: 0
stats:
maxHealth: 0
@@ -327319,7 +327330,6 @@ MonoBehaviour:
jumpForce: 0
damage: 0
health: 0
- invuln: 0
--- !u!60 &8919320862840140563
PolygonCollider2D:
m_ObjectHideFlags: 0
diff --git a/Assets/Scripts/Actors/Actor.cs b/Assets/Scripts/Actors/Actor.cs
index 30721a5..3acd51c 100644
--- a/Assets/Scripts/Actors/Actor.cs
+++ b/Assets/Scripts/Actors/Actor.cs
@@ -14,7 +14,8 @@ namespace MontanaJohns.Actors
{
[SerializeField] protected float gravityScale = 1.5f;
[SerializeField] protected Stats baseStats = Stats.DefaultBaseStats();
- [SerializeField] protected Transform groundCheckPoint;
+ [SerializeField] protected Transform groundCheckPoint1;
+ [SerializeField] protected Transform groundCheckPoint2;
[SerializeField] protected float invulnTime = 0f;
protected Rigidbody2D _rigidBody;
@@ -33,7 +34,7 @@ namespace MontanaJohns.Actors
public Stats stats;
public int health;
- public bool invuln;
+ private bool invuln;
protected virtual void Awake()
{
@@ -60,7 +61,7 @@ namespace MontanaJohns.Actors
protected virtual void FixedUpdate()
{
- if (!_animator.GetBool("airborn") && !Physics2D.OverlapCircle(groundCheckPoint.position, 0.2f, groundLayers))
+ if (!_animator.GetBool("airborn") && !(Physics2D.OverlapCircle(groundCheckPoint1.position, 0.2f, groundLayers) || Physics2D.OverlapCircle(groundCheckPoint2.position, 0.2f, groundLayers)))
{
_animator.SetTrigger("fall");
StartCoroutine(Falling());
@@ -98,7 +99,9 @@ namespace MontanaJohns.Actors
public virtual void Jump()
{
- if(Physics2D.OverlapCircle(groundCheckPoint.position, 0.2f, groundLayers))
+ if (isGrappling)
+ Use();
+ if(Physics2D.OverlapCircle(groundCheckPoint1.position, 0.2f, groundLayers) || Physics2D.OverlapCircle(groundCheckPoint2.position, 0.2f, groundLayers))
{
jumpCount = stats.maxJumps;
}
@@ -180,8 +183,11 @@ namespace MontanaJohns.Actors
{
_animator.SetBool("airborn", true);
- while (!Physics2D.OverlapCircle(groundCheckPoint.position, 0.2f, groundLayers))
+ bool falling = true;
+ while (falling)
{
+ if (Physics2D.OverlapCircle(groundCheckPoint1.position, 0.2f, groundLayers) || Physics2D.OverlapCircle(groundCheckPoint2.position, 0.2f, groundLayers))
+ falling = false;
yield return new WaitForEndOfFrame();
}