override protected void fireProjectile(GameObject bullet, Transform player) { if (channeler == null) { channeler = player.FindChild("channeler"); } bullet.transform.position = channeler.position; bullet.transform.right = player.right * Mathf.Sign(player.localScale.x); PoolableProjectile proj = bullet.GetComponent <PoolableProjectile>(); proj.SetOnCollision(onCollision, onCollisionTargets); bullet.GetComponent <BouncingProjectile>().numBounces = numBounces; }
void Fire() { if (target != null) { GameObject bullet = (GameObject)projectiles.getPooled(); bullet.SetActive(true); bullet.SendMessage("IgnoreCollider", collider2D); PoolableProjectile proj = bullet.GetComponent <PoolableProjectile>(); proj.SetOnCollision(ProjectileDamage, targets); bullet.transform.position = firePosition.position; bullet.rigidbody2D.AddForce((target.position - firePosition.position).normalized * projectileVelocity); } }
override protected void fireProjectile(GameObject bullet, Transform player) { if (channeler == null) { channeler = player.FindChild("channeler"); } PoolableProjectile proj = bullet.GetComponent <PoolableProjectile>(); proj.SetOnCollision(onCollision, onCollisionTargets); bullet.transform.position = channeler.position; bullet.transform.right = player.right * Mathf.Sign(player.localScale.x); bullet.rigidbody2D.AddForce(player.right * Mathf.Sign(player.localScale.x) * bulletVelocity); }
override protected void fireProjectile(GameObject bullet, Transform player) { if (channeler == null) { channeler = player.FindChild("channeler"); } bullet.transform.position = channeler.position; bullet.transform.right = player.up; //*Mathf.Sign (player.localScale.x); PoolableProjectile proj = bullet.GetComponent <PoolableProjectile>(); proj.SetOnDestroy(createExplosion, onDestroyTargets); proj.SetOnCollision(collisionExplosion, onCollisionTargets); //bullet.SendMessage("SetOnDestroy",new UpgradeAction(createExplosion,onDestroyTargets)); //bullet.SendMessage("SetOnCollision",new UpgradeAction(createExplosion,onCollisionTargets)); }
override protected void fireProjectile(GameObject bullet, Transform player) { if (channeler == null) { channeler = player.FindChild("channeler"); } PoolableProjectile proj = bullet.GetComponent <PoolableProjectile>(); proj.SetOnCollision(onCollision, onCollisionTargets); bullet.transform.position = channeler.position; float angle = 45 * Mathf.Sign(player.localScale.x); Vector3 facingDir = player.right * Mathf.Sign(player.localScale.x); Vector3 firingDir = Quaternion.AngleAxis(angle, Vector3.forward) * facingDir; bullet.rigidbody2D.AddForce(firingDir * bulletVelocity); }
GameObject getBullet(Transform spawnLoc) { GameObject bullet = clusterPool.getPooled(); bullet.SetActive(true); bullet.transform.position = spawnLoc.position; PoolableProjectile proj = bullet.GetComponent <PoolableProjectile>(); proj.IgnoreCollider(PlayerController.GlobalPlayerInstance.collider2D); proj.SetOnCollision(onCollision, onCollisionTargets); proj.collider2D.enabled = false; StartCoroutine(Timers.Countdown <GameObject>(0.1f, enableBulletCollision, bullet)); return(bullet); }