literally half of the game
This commit is contained in:
parent
1590b5faa6
commit
b842289076
77 changed files with 11904 additions and 72 deletions
|
|
@ -3,11 +3,27 @@ using UnityEngine;
|
|||
|
||||
public class Entity : MonoBehaviour
|
||||
{
|
||||
[Header("Sprite")]
|
||||
public SpriteRenderer sprite;
|
||||
[Header("Movement")]
|
||||
public float speed;
|
||||
[SerializeField] protected Rigidbody2D rb;
|
||||
public Vector3 moveDirection;
|
||||
public bool noMovement;
|
||||
public bool stalled;
|
||||
public bool isFacingRight;
|
||||
protected void FlipSprite(Vector2 lookDirection)
|
||||
{
|
||||
if (lookDirection.x > 0f && isFacingRight)
|
||||
{
|
||||
sprite.flipX = true;
|
||||
isFacingRight = !isFacingRight;
|
||||
}
|
||||
else if (lookDirection.x < 0f && !isFacingRight)
|
||||
{
|
||||
sprite.flipX = false;
|
||||
isFacingRight = !isFacingRight;
|
||||
}
|
||||
}
|
||||
protected virtual void Movement()
|
||||
{
|
||||
|
||||
|
|
@ -15,10 +31,14 @@ public class Entity : MonoBehaviour
|
|||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (!noMovement)
|
||||
if (!stalled)
|
||||
{
|
||||
Movement();
|
||||
rb.linearVelocity = moveDirection * speed;
|
||||
}
|
||||
else
|
||||
{
|
||||
rb.linearVelocity = Vector2.zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue