void Start() { // Get components // Physics rb2d = GetComponent <Rigidbody2D>(); animator = GetComponent <Animator>(); playerCollider = GetComponent <BoxCollider2D>(); // Ground Detection playerSize = playerCollider.size; colliderOffset = playerCollider.offset; boxSize = new Vector2(playerSize.x - subtractFromBoxSize, groundedSkin); // Audio playerAudioManager = FindObjectOfType <ObjectAudioManager>(); // Input inputManager = InputManager.instance; // Attacks attackColliderOffset = attackCollider.offset; leftAttackColliderOffset = -attackColliderOffset; }
DeathScript deathScript; // When health is 0, trigger this script private void Start() { // Set to max health health = maxHealth; visualHealth = health; audioManager = PlayerController.playerAudioManager; deathScript = GameObject.FindObjectOfType <DeathScript>(); // Script for when the player dies }
private void Awake() { nextFireTime = timeUntilFire; rb2d = GetComponent <Rigidbody2D>(); spriteRenderer = GetComponent <SpriteRenderer>(); spriteAnimator = GetComponent <SpriteAnimator>(); bulletCounter = GameObject.FindGameObjectWithTag("BulletManager").GetComponent <BulletCounter>(); playerController = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>(); playerAudioManager = GameObject.FindGameObjectWithTag("PlayerAudio").GetComponent <ObjectAudioManager>(); damageNumbers = GameObject.FindGameObjectWithTag("DamageNumbers").GetComponent <DamageNumbers>(); }
private void Start() { playerController = PlayerController.current; playerAudioManager = PlayerController.playerAudioManager; damageNumbers = FindObjectOfType <DamageNumbers>(); bulletCounter = FindObjectOfType <BulletCounter>(); if (affectedByForce) { forceScript = gameObject.AddComponent <EnemyGetAffectedByForce>() as EnemyGetAffectedByForce; } }
private void OnEnable() { rb2d = GetComponent <Rigidbody2D>(); sounds = GetComponent <ObjectAudioManager>(); // Get random X and Y for forces int randX = Random.Range(-maxRandomForce, maxRandomForce + 1); int randY = Random.Range(-maxRandomForce, maxRandomForce + 1); float randTime = Random.Range(0, 5); // Set time until coins move on their own timeUntilMove = Time.time + timeForMove + (randTime / 10); // Add random force rb2d.AddForce(new Vector2(randX, randY), ForceMode2D.Impulse); }
private void Start() { playerAudio = GameObject.FindGameObjectWithTag("PlayerAudio").GetComponent <ObjectAudioManager>(); score = GameObject.FindGameObjectWithTag("Score").GetComponent <ScoreManager>(); }