Create enemy
This commit is contained in:
+11
-11
@@ -25,37 +25,37 @@ public class Character : MonoBehaviour
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
protected void MoveTo(float inputHorizontal,float inputVertical)
|
||||
{
|
||||
float inputVertical = 0;
|
||||
|
||||
var groundCheck = Physics2D.BoxCast(_boxCollider.bounds.center, _boxCollider.bounds.size, 0f, Vector2.down, .1f, groundLayer);
|
||||
|
||||
float h_movement=0;
|
||||
float v_movement=0;
|
||||
if (groundCheck || _isOnLadder)
|
||||
{
|
||||
_isFall = false;
|
||||
float inputHorizontal = Input.GetAxisRaw("Horizontal");
|
||||
if (inputHorizontal > 0 && !_facingRight)
|
||||
h_movement=inputHorizontal ;
|
||||
if (h_movement > 0 && !_facingRight)
|
||||
{
|
||||
FlipCharacter();
|
||||
}
|
||||
if (inputHorizontal < 0 && _facingRight)
|
||||
if (h_movement < 0 && _facingRight)
|
||||
{
|
||||
FlipCharacter();
|
||||
}
|
||||
|
||||
animator.SetBool("Walk", inputHorizontal != 0);
|
||||
animator.SetBool("Walk", h_movement != 0);
|
||||
|
||||
if (IsLadder(Vector2.down))
|
||||
{
|
||||
_isOnLadder = true;
|
||||
inputVertical = Input.GetAxisRaw("Vertical");
|
||||
v_movement=inputVertical;
|
||||
|
||||
if (inputVertical > 0)
|
||||
if (v_movement > 0)
|
||||
{
|
||||
if (!IsLadder(Vector2.up))
|
||||
{
|
||||
inputVertical = 0;
|
||||
v_movement = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class Character : MonoBehaviour
|
||||
{
|
||||
_isOnLadder = false;
|
||||
}
|
||||
_body.velocity = new Vector2(inputHorizontal * MovementSpeed, inputVertical * MovementSpeed);
|
||||
_body.velocity = new Vector2(h_movement * MovementSpeed, v_movement * MovementSpeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user