Fix falling on ladder issue
This commit is contained in:
@@ -96,6 +96,7 @@ public class Character : MonoBehaviour
|
|||||||
var raycastHit=Physics2D.BoxCast(_boxCollider.bounds.center, _boxCollider.bounds.size, 0f, direction, .1f, _mapLayer);
|
var raycastHit=Physics2D.BoxCast(_boxCollider.bounds.center, _boxCollider.bounds.size, 0f, direction, .1f, _mapLayer);
|
||||||
if (raycastHit)
|
if (raycastHit)
|
||||||
{
|
{
|
||||||
|
|
||||||
var mapElement = raycastHit.transform.GetComponent<MapElement>();
|
var mapElement = raycastHit.transform.GetComponent<MapElement>();
|
||||||
|
|
||||||
return mapElement == null ? MapElementType.Empty : mapElement.ElementSO.ElementType;
|
return mapElement == null ? MapElementType.Empty : mapElement.ElementSO.ElementType;
|
||||||
@@ -117,12 +118,14 @@ public class Character : MonoBehaviour
|
|||||||
}
|
}
|
||||||
if (_isFalling)
|
if (_isFalling)
|
||||||
{
|
{
|
||||||
if (GetMapElement(Vector2.down)==MapElementType.Ladder)
|
|
||||||
{
|
|
||||||
_isOnLadder = true;
|
|
||||||
}
|
|
||||||
_body.velocity = new Vector2(0, _body.velocity.y);
|
_body.velocity = new Vector2(0, _body.velocity.y);
|
||||||
animator.SetBool("Walk", false);
|
animator.SetBool("Walk", false);
|
||||||
|
|
||||||
|
if (GetMapElement(Vector2.down)==MapElementType.Ladder)
|
||||||
|
{
|
||||||
|
_body.velocity = Vector2.zero;
|
||||||
|
_isOnLadder = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user