This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

IGame.SpawnProjectile() not working when called in callbacks from ProjectileCreatedCallback

Here you can find all solved gameplay problems and bugs (beginning from Pre-Alpha 1.8.8).
Forum rules
By using the forum you agree to the following rules. For this forum you also need to follow these additional rules.
Locked
NearHuscarl
Superfighter
Superfighter
Posts: 97
Joined: Thu Feb 07, 2019 4:36 am

IGame.SpawnProjectile() not working when called in callbacks from ProjectileCreatedCallback

Post by NearHuscarl » Sun Apr 05, 2020 6:36 pm

Minimal sample code

Code: Select all

public void OnStartup()
{
	Game.SpawnProjectile(ProjectileItem.BAZOOKA, Vector2.Zero, Vector2.Zero); // works
	Events.ProjectileCreatedCallback.Start((p) =>
	{
		Game.SpawnProjectile(ProjectileItem.BAZOOKA, Vector2.Zero, Vector2.Zero); // not working
	});
}
0 x
Image

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1887
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 36

Post by Gurt » Mon Apr 06, 2020 10:55 pm

Woop! Those projectiles are now in the void. Fixed after v.1.3.5 which will trigger the ProjectileCreatedCallback to be run next update instead of current update in case you call it inside ProjectileCreatedCallback.
0 x
Gurt

Locked