/*void OnCollisionEnter2D(Collision2D collision) * { * GameObject obj=collision.gameObject; * TopDownMovementWithRigidBody mov =obj.GetComponent<TopDownMovementWithRigidBody>(); * if (obj.CompareTag("Player")&&mov!=null){ * * mov.damagePlayer(attack); * } * }*/ void OnTriggerStay2D(Collider2D other) { TopDownMovementWithRigidBody mov = other.GetComponent <TopDownMovementWithRigidBody>(); if (other.CompareTag("Player") && mov != null) { mov.damagePlayer(attack); } }
// Use this for initialization void Start() { player = GameObject.FindWithTag("Player").GetComponent <TopDownMovementWithRigidBody>(); }
// Use this for initialization void Start() { targetScript = targetObject.GetComponent <TopDownMovementWithRigidBody>(); }