Browse Source

cones no longer trigger stuff falsely

master
Josh 2 years ago
parent
commit
f0aff9e5fd
  1. 9
      unity/Assets/Scripts/DragonMovement.cs

9
unity/Assets/Scripts/DragonMovement.cs

@ -65,11 +65,13 @@ public class DragonMovement : MonoBehaviour
private void OnTriggerEnter2D(Collider2D collision) private void OnTriggerEnter2D(Collider2D collision)
{ {
/*
GameObject cone = transform.Find(CONE_NAME)?.gameObject; GameObject cone = transform.Find(CONE_NAME)?.gameObject;
if (cone) if (cone)
{ {
GameObject.Destroy(cone); GameObject.Destroy(cone);
} }
*/
CheckCloudCollision(collision); CheckCloudCollision(collision);
@ -102,6 +104,8 @@ public class DragonMovement : MonoBehaviour
if (collision.CompareTag("Fireball")) if (collision.CompareTag("Fireball"))
{ {
Fireball fireball = collision.GetComponent<Fireball>(); Fireball fireball = collision.GetComponent<Fireball>();
if (fireball.transform.parent.gameObject == this.gameObject)
return;
if (fireball.AttackType == AttackType.CONE) if (fireball.AttackType == AttackType.CONE)
{ {
@ -155,6 +159,9 @@ public class DragonMovement : MonoBehaviour
_animator = this.GetComponent<Animator>(); _animator = this.GetComponent<Animator>();
_trail.startColor = _color; _trail.startColor = _color;
_trail.endColor = _color; _trail.endColor = _color;
Ammo = 5;
_attackType = AttackType.CONE;
} }
private void Update() private void Update()
@ -204,6 +211,8 @@ public class DragonMovement : MonoBehaviour
fireball.name = CONE_NAME; fireball.name = CONE_NAME;
fireball.GetComponent<Fireball>().AttackType = AttackType.CONE; fireball.GetComponent<Fireball>().AttackType = AttackType.CONE;
fireball.transform.parent = this.transform; fireball.transform.parent = this.transform;
Rigidbody2D rigidBody = fireball.AddComponent<Rigidbody2D>();
rigidBody.isKinematic = true;
} }
} }

Loading…
Cancel
Save