public virtual void Init(Unit u) { ready = true; UsedBy = u; slave = new GameObject("Slave").AddComponent <CoroutineSlave>(); slave.transform.parent = UsedBy.transform; foeTag = UsedBy.gameObject.tag == "Player" ? "Enemy" : "Player"; foeAttackTag = foeTag == "Enemy" ? "EnemyProjectile" : "PlayerProjectile"; }
public void Init(RangedAbility a, string t, Vector3 direction, float lt) { base.Init(a, t, lt); rb = GetComponent <Rigidbody>(); sr = GetComponent <SpriteRenderer>(); rb.constraints = RigidbodyConstraints.FreezePositionY; rb.freezeRotation = true; rb.useGravity = false; string tagNLayer = Ability.UsedBy.tag == "Player" ? "PlayerProjectile" : "EnemyProjectile";; transform.tag = tagNLayer; gameObject.layer = LayerMask.NameToLayer(tagNLayer); Vector3 temp = ((Player)Ability.UsedBy).ProjectileSpawn.position; transform.position = new Vector3(temp.x, 0.01f, temp.z); sr.sprite = Ability.projectileSprite; sr.sortingLayerName = "Projectile"; GetComponent <SphereCollider>().radius = .125f; HitSlave = new GameObject().AddComponent <CoroutineSlave>(); HitSlave.gameObject.transform.parent = transform; Fire(direction); }
private void Awake() { slave = this; }