void Start() { rb = GetComponent <Rigidbody2D>(); target = GameObject.FindObjectOfType <GoblinScript>(); moveDirection = (target.transform.position - transform.position).normalized * ms; rb.velocity = new Vector2(moveDirection.x, moveDirection.y); Destroy(gameObject, 3f); }
// Start is called before the first frame update private void Start() { anim = GetComponent <Animator>(); myTransform = transform; attackCountdown = attackDelay; potionTransform = bombPrefab.transform; animThrowCountdown = animThrowDelay; ///Goblin = GameObject.FindGameObjectWithTag("Goblin").GetComponent<GoblinScript>() is inappropriate in this context ///because the Goblins will find **any** object with this tag in the scene. Using this caused the goblins to continue ///throwing bombs even after it died since other Goblins were alive. goblin = gameObject.GetComponent <GoblinScript>(); }
//particle effect object lifetime value void Start() { startPos = transform.position; playerHPScript = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealth>(); goblin = GameObject.FindGameObjectWithTag("Goblin").GetComponent <GoblinScript>(); }