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);
});
}
Code: Select all
Gets or Sets the current velocity that the projectile covers each second. Note: Sync over server-client assumes the velocity stays intact and changing this each update can make it look janky on clients. Note: You can not set a velocity greater than the max speed of the projectile and not set a velocity less than 100 in magnitude.