void Awake() { player = GameObject.FindGameObjectWithTag("Player"); lunaCharacterController = GetComponent<LunaCharacterController>(); playerScript = GetComponent<PlayerScript>(); pStats = GetComponent<AbilityBar> (); fireballSpawn = GameObject.FindGameObjectWithTag("FireballSpawn"); }
// Use this for initialization void Start() { rigidBody2D = GetComponent<Rigidbody2D>(); lunaCharacterController = GameObject.FindGameObjectWithTag("Player").GetComponent<LunaCharacterController>(); Quaternion newRotation; //if the character is facing to the right, shoot to the right if(lunaCharacterController.m_FacingRight) { rigidBody2D.velocity = new Vector2(speed, 0f) * Time.deltaTime; //rotate the fireball to face the correct direction newRotation = Quaternion.Euler(0,0,0); transform.rotation = newRotation; } //if the character id facing left, shoot to the left else if (!lunaCharacterController.m_FacingRight) { rigidBody2D.velocity = new Vector2(speed * -1f, 0f) * Time.deltaTime; newRotation = Quaternion.Euler(0,180,0); transform.rotation = newRotation; } }
private void Awake() { m_Character = GetComponent<LunaCharacterController>(); }