// Start is called before the first frame update void Start() { if (anim == null) { anim = gameObject.GetComponent <Animator>(); } if (cam == null) { cam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>(); } if (rb == null) { rb = gameObject.GetComponent <Rigidbody2D>(); } if (playerAttack == null) { playerAttack = gameObject.GetComponent <PlayerAttack>(); } playerHealth = GetComponent <PlayerHealth>(); playerFaceDir = faceDir.Right; lockFaceDir = false; }
void SetDirectionFacing(string str) { /* * 1 - Left * 2 - Right * 3 - Up * 4 - Down */ if (str == "Left") { anim.SetInteger("faceDir", 1); playerFaceDir = faceDir.Left; } else if (str == "Right") { anim.SetInteger("faceDir", 2); playerFaceDir = faceDir.Right; } else if (str == "Up") { anim.SetInteger("faceDir", 3); playerFaceDir = faceDir.Up; } else if (str == "Down") { anim.SetInteger("faceDir", 4); playerFaceDir = faceDir.Down; } }
public void Spawn() { PlayerChar = Instantiate(MainChar, GridGen.tilesGO[0].transform); PlayerSCR = PlayerChar.GetComponent <player>(); OverLayInstant = Instantiate(OverLay, transform.Find("MainPanel").transform); Image temp = OverLayInstant.GetComponentInChildren <Image>(); FD = OverLayInstant.GetComponentInChildren <faceDir>(); temp.sprite = StyleContainer.Instance.Styles[PlayerPrefs.GetInt("Style")].SPR_Player; OverlayRT = OverLayInstant.GetComponent <RectTransform>(); OverLayImg = OverLayInstant.GetComponentInChildren <Image>(); SpawnEgg(PlayerSCR.location); }