Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the 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: 89
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: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 31

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