finally fixed player getting stuck

This commit is contained in:
2020-02-01 23:10:39 -05:00
parent 9aca11b57b
commit 0e16dc5f9f
5 changed files with 21 additions and 23 deletions

View File

@@ -48168,8 +48168,8 @@ Rigidbody2D:
m_SleepingMode: 1
m_CollisionDetection: 1
m_Constraints: 4
--- !u!61 &1671840919
BoxCollider2D:
--- !u!70 &1671840919
CapsuleCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
@@ -48181,19 +48181,9 @@ BoxCollider2D:
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: -0.01, y: -0.62}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 4, y: 4}
newSize: {x: 1, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 1
serializedVersion: 2
m_Size: {x: 0.9, y: 2.79}
m_EdgeRadius: 0
m_Offset: {x: 0, y: -0.64}
m_Size: {x: 0.9, y: 2.75}
m_Direction: 0
--- !u!212 &1671840920
SpriteRenderer:
m_ObjectHideFlags: 0

View File

@@ -7,7 +7,7 @@ public class BugMovement : MonoBehaviour
[SerializeField] private float secondsGoingLeft = 1;
[SerializeField] private float secondsGoingRight = 1;
[SerializeField] private float movementSpeed = 10;
[SerializeField] BoxCollider2D playerCollider;
[SerializeField] Collider2D playerCollider;
[SerializeField] EventControls eventControls;
[SerializeField] Player player;
@@ -26,7 +26,7 @@ public class BugMovement : MonoBehaviour
private void Update()
{
if (HasEncounteredPlayer())
eventControls.TriggerEvent(playerCollider, GetComponent<BoxCollider2D>(), player);
eventControls.TriggerEvent(playerCollider, GetComponent<Collider2D>(), player);
var totalFramesGoingLeft = framesPerSecond * secondsGoingLeft;
var totalFramesGoingRight = framesPerSecond * secondsGoingRight;

View File

@@ -27,14 +27,14 @@ public class Player : MonoBehaviour
private Rigidbody2D rigidBody;
new private BoxCollider2D collider;
new private Collider2D collider;
private Animator animator;
private bool isMovementEnabled = true;
private void Start()
{
rigidBody = GetComponent<Rigidbody2D>();
collider = GetComponent<BoxCollider2D>();
collider = GetComponent<Collider2D>();
animator = GetComponent<Animator>();
currentHealth = startHealth;
currentStamina = startStamina;
@@ -173,10 +173,10 @@ public class Player : MonoBehaviour
private bool IsPlayerOnWall(bool ignoreGround = false)
{
return IsPointOnWall(transform.position + new Vector3(0, collider.bounds.extents.y * 0.6f, 0), ignoreGround) ||
IsPointOnWall(transform.position - new Vector3(0, collider.bounds.extents.y * 0.25f, 0), ignoreGround) ||
return IsPointOnWall(transform.position + new Vector3(0, collider.bounds.extents.y * 0.52f, 0), ignoreGround) ||
IsPointOnWall(transform.position - new Vector3(0, collider.bounds.extents.y * 0.24f, 0), ignoreGround) ||
IsPointOnWall(transform.position - new Vector3(0, collider.bounds.extents.y * 0.8f, 0), ignoreGround) ||
IsPointOnWall(transform.position - new Vector3(0, collider.bounds.extents.y * 1.5f, 0), ignoreGround);
IsPointOnWall(transform.position - new Vector3(0, collider.bounds.extents.y * 1.45f, 0), ignoreGround);
}
private bool IsPointOnWall(Vector2 position, bool ignoreGround = false)

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bf9fc495ca38d7d4d804ad1d2df0f4c5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: bf9fc495ca38d7d4d804ad1d2df0f4c5
guid: 93ff3d1c20b08c048a2ae60a4b35e73f
folderAsset: yes
DefaultImporter:
externalObjects: {}