some issues with breakable walls
This commit is contained in:
@@ -28,7 +28,7 @@ public abstract class Character : MonoBehaviour
|
||||
protected bool isAllowVertical = true;
|
||||
protected bool isAllowRight = true;
|
||||
protected bool isAllowLeft = true;
|
||||
|
||||
float v_movement = 0;
|
||||
private void Start()
|
||||
{
|
||||
_body = GetComponent<Rigidbody2D>();
|
||||
@@ -41,12 +41,12 @@ public abstract class Character : MonoBehaviour
|
||||
|
||||
_isOnBridge = mapElement == MapElementType.Bridge && !_isFalling;
|
||||
|
||||
float v_movement = 0;
|
||||
|
||||
if (mapElement == MapElementType.Wall || _isOnLadder || _isOnBridge || mapElement == MapElementType.BreakableWall)
|
||||
{
|
||||
var leftCheck = GetMapElement(Vector2.left);
|
||||
var rightCheck = GetMapElement(Vector2.right);
|
||||
if (leftCheck == MapElementType.Wall)
|
||||
if (leftCheck == MapElementType.Wall || leftCheck == MapElementType.BreakableWall)
|
||||
{
|
||||
isAllowLeft = false;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public abstract class Character : MonoBehaviour
|
||||
{
|
||||
isAllowLeft = true;
|
||||
}
|
||||
if (rightCheck == MapElementType.Wall)
|
||||
if (rightCheck == MapElementType.Wall || rightCheck== MapElementType.BreakableWall)
|
||||
{
|
||||
isAllowRight = false;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public abstract class Character : MonoBehaviour
|
||||
|
||||
private MapElementType GetMapElement(Vector2 direction)
|
||||
{
|
||||
var raycastHit = Physics2D.BoxCast(_boxCollider.bounds.center, _boxCollider.bounds.size, 0f, direction, 0.1f, _mapLayer);
|
||||
var raycastHit = Physics2D.BoxCast(_boxCollider.bounds.center, _boxCollider.bounds.size, 0f, direction, 0.2f, _mapLayer);
|
||||
if (raycastHit)
|
||||
{
|
||||
var mapElement = raycastHit.transform.GetComponent<MapElement>();
|
||||
@@ -113,13 +113,6 @@ public abstract class Character : MonoBehaviour
|
||||
{
|
||||
return MapElementType.Empty;
|
||||
}
|
||||
if (mapElement.ElementSO.ElementType == MapElementType.BreakableWall)
|
||||
{
|
||||
if (mapElement.GetComponent<BoxCollider2D>().isTrigger)
|
||||
{
|
||||
return MapElementType.Empty;
|
||||
}
|
||||
}
|
||||
return mapElement.ElementSO.ElementType;
|
||||
}
|
||||
return MapElementType.Empty;
|
||||
|
||||
Reference in New Issue
Block a user