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.

Cannot set IProjectile.Position when it is ProjectileItem.GRENADE_LAUNCHER

Did you encounter a problem, exploit, glitch or bug while playing the game or running the dedicated server software? Tell us about it here.
Forum rules
By using the forum you agree to the following rules. For this forum you also need to follow these additional rules.
Post Reply
NearHuscarl
Superfighter
Superfighter
Posts: 79
Joined: Thu Feb 07, 2019 4:36 am

Cannot set IProjectile.Position when it is ProjectileItem.GRENADE_LAUNCHER

Post by NearHuscarl » Thu Mar 26, 2020 10:41 am

The grenade launcher projectile keep falling although I set it to the same position in the update loop

Code to reproduce

Code: Select all

private static IProjectile m_projectile;

public void OnStartup()
{
	var me = Game.GetPlayers()[0];
	me.GiveWeaponItem(WeaponItem.GRENADE_LAUNCHER);

	Events.ProjectileCreatedCallback.Start((ps) =>
	{
		foreach (var p in ps)
		{
			if (p.ProjectileItem == ProjectileItem.GRENADE_LAUNCHER)
			{
				m_projectile = p;
				break;
			}
		}
	});

	Events.UpdateCallback.Start((e) =>
	{
		if (m_projectile == null) return;
		m_projectile.Position = Vector2.Zero; // set to any empty space position depend on your map
		m_projectile.Velocity = Vector2.Zero;
		Game.WriteToConsole(m_projectile.Position);
	});
}
0 x

Post Reply