public static void Spawn(Vector2 position, Vector2 velocity, float rotation, float angularVelocity, Sprite sprite, bool flip) { if (Prefab == null) { Prefab = Resources.Load <GameObject>("Items/Effects/Mag"); } // Spawn at position and z rotation. GameObject GO = ObjectPool.Instantiate(Prefab, PoolType.FLYING_MAG); FlyingMag mag = GO.GetComponent <FlyingMag>(); mag.Init(position, velocity, rotation, angularVelocity, 3f, sprite, flip); }
public void CallbackSpawnMag() { // Determine if we can spawn... if (FlyingMagazine.MagSprite == null || FlyingMagazine.RealMag == null) { return; } if (FlyingMagazine.Count <= 0) { return; } for (int i = 0; i < FlyingMagazine.Count; i++) { float magniutude = Mathf.Abs(FlyingMagazine.RandomForce); float random = UnityEngine.Random.Range(-magniutude, magniutude); float angmagniutude = Mathf.Abs(FlyingMagazine.RandomRotation); float angrandom = UnityEngine.Random.Range(-angmagniutude, angmagniutude); FlyingMag.Spawn(FlyingMagazine.RealMag.transform.position, FlyingMagazine.RealMag.transform.up * -1f * (FlyingMagazine.Force + random), FlyingMagazine.RealMag.transform.rotation.eulerAngles.z, (FlyingMagazine.Rotation + angrandom) * (!Player.Local.Direction.Right ? -1f : 1f), FlyingMagazine.MagSprite, !Player.Local.Direction.Right); } }