Add flipping to mobcats

This commit is contained in:
Jens Pitkänen 2019-08-19 00:55:47 +03:00
parent d6cf5a2fb5
commit 343cf5bc3a
2 changed files with 7 additions and 0 deletions

View File

@ -447,6 +447,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
Anim: {fileID: 5842195514978149329}
SpriteRenderer: {fileID: 4848125059538075066}
--- !u!1 &3991584792453052187
GameObject:
m_ObjectHideFlags: 0

View File

@ -12,6 +12,7 @@ namespace Saltosion.OneWeapon.Enemies {
[RequireComponent(typeof(RangedAttackFollowed))]
public class MobCat : MonoBehaviour {
public Animator Anim;
public SpriteRenderer SpriteRenderer;
private Enemy Enemy;
private PlayerSighted FollowTrigger;
@ -47,6 +48,11 @@ namespace Saltosion.OneWeapon.Enemies {
Anim.Play("Walk");
}
Anim.SetFloat("Speed", Enemy.Movement.SpeedPercentage);
if (Enemy.Movement.SpeedPercentage > 0.1) {
SpriteRenderer.flipX = Vector2.Dot(Enemy.Movement.Direction, Vector2.left) < 0;
} else {
SpriteRenderer.flipX = Vector2.Dot(FollowBehaviour.TargetDirection, Vector2.left) < 0;
}
}
}
}