// Use this for initialization void Start() { player = GetComponent <PlayerObjectScript>(); if (GameHUDCanvas != null) { GameHUD = GameHUDCanvas.transform.Find("HUD").gameObject; WorkBenchHUD = GameHUDCanvas.transform.Find("WorkBenchMenu").gameObject; InventoryHUD = GameHUDCanvas.transform.Find("Inventory").gameObject; } }
void OnCollisionStay(Collision hit) { if (hit.gameObject.tag == "Player") { if (!isAttacking) { isAttacking = true; PlayerObjectScript player = hit.gameObject.GetComponent <PlayerObjectScript>(); DealDamage(player); lastAttackTime = Time.time; } } }
// Start is called before the first frame update private void Start() { fireSoundSource = GetComponent <AudioSource>(); fireSoundSource.clip = fireSound; healthSystem = new HealthSystem(health); Transform healthBarTransform = Instantiate(pfHealthBar, new Vector3(this.transform.position.x, (float)(this.transform.position.y + 0.5)), Quaternion.identity, this.transform); HealthBar healthBar = healthBarTransform.GetComponent <HealthBar>(); healthBar.Setup(healthSystem); playerObject = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerObjectScript>(); rb = GetComponent <Rigidbody2D>(); player = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>(); float delay = UnityEngine.Random.Range(2f, 5f); float rate = UnityEngine.Random.Range(2f, 4f); // methodName, time, and repeat rate InvokeRepeating("Fire", 1f, 1f); }
void Start() { RocketSpawnPoint = transform.GetChild(0); POScript = transform.GetComponentInParent <PlayerObjectScript> (); }
void Start() { gameMusicSound = GetComponent <AudioSource>(); gameMusicSound.Play(); player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerObjectScript>(); }