public IGameObject SpawnProjectile(string name, Vector2 location, Vector2 initialDirection) { IGameObject projectile = null; if (!cachedProjectiles.ContainsKey(name)) { projectile = gameObjectFactory.GetGameObject(name, usedAsTemplate: true); projectile.Active = false; cachedProjectiles.Add(name, projectile); } projectile = gameObjectFactory.CopyExistingGameObject(cachedProjectiles[name]); projectile.Position = location; var projMoveBehavior = projectile.GetComponent <IBehaviorComponent>().GetBehavior("moveBehavior") as BaseProjectileMovementBehavior; projMoveBehavior.InitialDirection = initialDirection; projectile.PostInitialize(); return(projectile); }