Commit 9580cf3a authored by 15김민규's avatar 15김민규

벽에 낑기는거 해결 완료.

parent 24bf0a24
......@@ -61,7 +61,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!1 &1734061800721222
GameObject:
m_ObjectHideFlags: 1
......@@ -300,8 +300,6 @@ MonoBehaviour:
knockbackPercentage:
- 0.5
MovementLock: 0
bumped: 0
bumpable: 1
attackRange: 1.2
--- !u!114 &114173716467154830
MonoBehaviour:
......@@ -378,7 +376,7 @@ SpriteRenderer:
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: -2078941185
m_SortingLayer: 7
m_SortingLayer: 8
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 71335108d30aa0e4a90179a09895440e, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
......
......@@ -60,3 +60,9 @@ MonoBehaviour:
- {fileID: 1896221696921858, guid: 6051c7354232afa45bf71a1032a49418, type: 2}
EnemySpawnCount: 0
EnemyDeadCount: 0
layerMaskWall:
serializedVersion: 2
m_Bits: 256
layerMaskPlatform:
serializedVersion: 2
m_Bits: 2304
......@@ -70,12 +70,12 @@ public class Enemy : MonoBehaviour {
currHealth = maxHealth;
Invisible = MovementLock = KnockbackLock = false;
if (enemyManager.DropTableByID.ContainsKey(monsterID)) { dropTable = enemyManager.DropTableByID[monsterID]; }
PlayerDistance = Vector2.Distance(enemyManager.Player.transform.position, transform.parent.position);
PlayerDistance = Vector2.Distance(GameManager.Instance.player.transform.position, transform.parent.position);
}
protected virtual void FixedUpdate()
{
PlayerDistance = Vector2.Distance(enemyManager.Player.transform.position, transform.parent.position);
PlayerDistance = Vector2.Distance(GameManager.Instance.player.transform.position, transform.parent.position);
}
// When damaged
......
......@@ -8,8 +8,8 @@ public class EnemyGround : Enemy {
public float attackRange;
public int MoveDir { get; private set; }
public bool[] WallTest { get; private set; }
public bool[] CliffTest { get; private set; }
public bool[] WallTest;
public bool[] CliffTest;
protected override void Awake()
{
......@@ -38,7 +38,6 @@ public class EnemyGround : Enemy {
// - Check whether enemy is near to cliff
private void CheckCliff()
{
Vector2 velocity = transform.parent.GetComponent<Rigidbody2D>().velocity;
Vector2 colliderSize = transform.parent.GetComponent<BoxCollider2D>().size;
foreach (int Dir in Enum.GetValues(typeof(NumeratedDir)))
......@@ -46,8 +45,7 @@ public class EnemyGround : Enemy {
Vector2 origin = (Vector2)transform.parent.position + Dir * new Vector2(colliderSize.x / 2.0f, 0);
Vector2 direction = Vector2.down;
float distance = colliderSize.y / 4.0f;
int layerMask = LayerMask.NameToLayer("platform");
RaycastHit2D hit = Physics2D.Raycast(origin, direction, distance, layerMask);
RaycastHit2D hit = Physics2D.Raycast(origin, direction, distance, enemyManager.layerMaskPlatform);
CliffTest[(Dir + 1) / 2] = (hit.collider == null);
}
......@@ -60,11 +58,10 @@ public class EnemyGround : Enemy {
foreach (int Dir in Enum.GetValues(typeof(NumeratedDir)))
{
Vector2 origin = (Vector2)transform.parent.position + new Vector2(Dir * colliderSize.x / 2.0f, colliderSize.y);
Vector2 origin = (Vector2)transform.parent.position + new Vector2(Dir * colliderSize.x / 2.0f, colliderSize.y / 2.0f);
Vector2 direction = Vector2.right * Dir;
float distance = 0.5f;
LayerMask layerMask = LayerMask.GetMask("Wall", "OuterWall");
RaycastHit2D hit = Physics2D.Raycast(origin, direction, distance, layerMask);
float distance = 0.2f;
RaycastHit2D hit = Physics2D.Raycast(origin, direction, distance, enemyManager.layerMaskWall);
WallTest[(Dir + 1) / 2] = (hit.collider != null);
}
......
......@@ -33,6 +33,9 @@ public class EnemyManager : Singleton<EnemyManager>
private uint EnemySpawnCount;
public uint EnemyDeadCount;
// wall or platform
public LayerMask layerMaskWall;
public LayerMask layerMaskPlatform;
// method
// Constructor - protect calling raw constructor
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment