Projectile HitEffects

A quick guide for setting up projectile HitEffects.

A projectile's HitEffects are the visual effects that play upon a projectile impacting an object or wall. They can be changed or set as desired. The easiest way to set up HitEffects is to copy the vfx object from an existing gun in the vanilla game, though it is possible to assign your own custom vfx object if you know how to make one.

Basic Variables

A projectile's hitEffects can be accessed easily via projectile.hitEffects. Via this method, you can adjust the following variables, and more;


alwaysUseMidair determines whether or not a projectile will attempt to use its mid-air effect upon impacting anything. Usually, the midair effect will only play if the projectile reaches the end of its range mid-flight, however, if this variable is set to true the projectile will always use its mid-air effects.

midairInheritsFlip determines whether the midair vfx will flip along the horizontal axis to match its base projectile. If this is set to true, projectiles fired to the left will have their midair effects flipped to face the left. This is only noticeable on mid-air effects that are notably directional.

midairInheritsRotation determines whether the midair vfx will rotate to match the rotation of its base projectile. If this is set to true, projectiles fired at (for example) a 90-degree angle will have their vfx rotated by 90 degrees. This is only noticeable on mid-air effects that are notably directional.

Copying From Existing Guns

The easiest way to set up a projectile's hitEffects is to copy appropriate effects from an existing vanilla gun. Many guns in vanilla actually do this themselves; The Wind-Up Gun, Void Marshal, and Laser Rifle all use the same hitEffects.

To keep things simple, you may choose to always use the midair effect, as explained in the previous section. This will mean you only have to change a couple of variables to make the effects work.

projectile.hitEffects.overrideMidairDeathVFX = (PickupObjectDatabase.GetById(89) as Gun).DefaultModule.projectiles[0].hitEffects.overrideMidairDeathVFX;

This is an example of copying the midair effects from a base game gun, in this case, the Rogue Special and it's green laser circles. The gun is referenced via its numerical id, in this case, 89. If you want to copy from a different gun's hitEffects, you can change that number to the numerical id of a different gun. A full list of numerical ids can be found here.

To copy the other effects of a vanilla gun, you can use similar code;

projectile.hitEffects.tileMapHorizontal = (PickupObjectDatabase.GetById(89) as Gun).DefaultModule.projectiles[0].hitEffects.tileMapHorizontal;
projectile.hitEffects.tileMapVertical = (PickupObjectDatabase.GetById(89) as Gun).DefaultModule.projectiles[0].hitEffects.tileMapVertical;

Last updated