Merge branch 'master' of https://github.com/jyapayne/DemonShanker2
Conflicts: Assets/Scripts/PlayerController.cs
This commit is contained in:
commit
fa03db0e61
1 changed files with 19 additions and 2 deletions
|
|
@ -12,6 +12,9 @@ public class PlayerController : MonoBehaviour {
|
||||||
public GameObject vvAura;
|
public GameObject vvAura;
|
||||||
public int swigCounter;
|
public int swigCounter;
|
||||||
private GameController gameController;
|
private GameController gameController;
|
||||||
|
public GameObject playerSprite;
|
||||||
|
|
||||||
|
enum Direction {Left, Right};
|
||||||
|
|
||||||
void Start() {
|
void Start() {
|
||||||
GameObject gameControllerObject = GameObject.FindWithTag("GameController");
|
GameObject gameControllerObject = GameObject.FindWithTag("GameController");
|
||||||
|
|
@ -29,6 +32,17 @@ public class PlayerController : MonoBehaviour {
|
||||||
animator = GameObject.Find("PlayerSprite").GetComponent<Animator>();
|
animator = GameObject.Find("PlayerSprite").GetComponent<Animator>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MakePlayerSpriteFace(Direction dir)
|
||||||
|
{
|
||||||
|
Vector3 scaleVec = playerSprite.transform.localScale;
|
||||||
|
if (dir == Direction.Left) {
|
||||||
|
scaleVec.x = -1;
|
||||||
|
} else if (dir == Direction.Right) {
|
||||||
|
scaleVec.x = 1;
|
||||||
|
}
|
||||||
|
playerSprite.transform.localScale = scaleVec;
|
||||||
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (Input.GetButton("Fire1") && Time.time > nextFire)
|
if (Input.GetButton("Fire1") && Time.time > nextFire)
|
||||||
|
|
@ -61,9 +75,12 @@ public class PlayerController : MonoBehaviour {
|
||||||
|
|
||||||
if (moveHorizontal < 0) {
|
if (moveHorizontal < 0) {
|
||||||
playerAngle.eulerAngles = new Vector3(0f, -180f, 0f);
|
playerAngle.eulerAngles = new Vector3(0f, -180f, 0f);
|
||||||
|
MakePlayerSpriteFace(Direction.Left);
|
||||||
}
|
}
|
||||||
if (moveHorizontal > 0)
|
if (moveHorizontal > 0) {
|
||||||
playerAngle.eulerAngles = new Vector3 (0f, 0f, 0f);
|
playerAngle.eulerAngles = new Vector3 (0f, 0f, 0f);
|
||||||
|
MakePlayerSpriteFace(Direction.Right);
|
||||||
|
}
|
||||||
if (moveVertical < 0)
|
if (moveVertical < 0)
|
||||||
playerAngle.eulerAngles = new Vector3(0f, -270f, 0f);
|
playerAngle.eulerAngles = new Vector3(0f, -270f, 0f);
|
||||||
if (moveVertical > 0)
|
if (moveVertical > 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue