#Free projectile system

1 messages · Page 1 of 1 (latest)

urban moss
#

How to use:

Create a new BallisticProfile or use one of the provided. You can create them by right clicking create > Projectiles > Ballistic Profile. it takes in imperial units ( or you can do metric directly) with a Range (distance from starting point), Velocity (current velocity at the distance), and Drop (how far down from the starting direction downwards (this value should be positive)). I would recommend a step of around 200-250 units between each of the entries.

Create a SurfaceEffectProfile or use the provided (theres only the default assigned) by right clicking create > Projectiles > Surface Effect Profile. Theres a few ones by default you can add more in the script. each takes in a surface type, decal projector, impact audio clips, and a prefab for the vfx. Any obj that you want to do effects on, you have to add the Surface component. (just returns the type)

Add the projectile manager component to a gameObj in your scene, or use the provided prefab and assign the fields.

in your weapons script get a ref to the ProjectileManager, and make an int for the ballisticProfileId (this will be used to pass in the Fire() of the projectile manager).

Before firing you must register the ballistic profile with the manager by using RegisterBallisticProfile(BallisticProfile profile) you can do this in equip or start

When firing you call the projectileManager.Fire(Vector3 position, Vector3 direction, int profileId, float damage, float hitForce, float unpinRagdollAmount) (you can remove the unpin ragdoll, im using puppet master so i had it there. (everything else is commented out, just forgot about that)

There is a HandleImpact(int projectileIndex) method where you can do all the necessary things you would want to

#

pretty much it, all visual assets are really just for demonstration, threw them together with free stuff before posting

urban moss
#

registering the profile :
if (_projectileManager != null) { _ballisticProfileId = _projectileManager.RegisterBallisticProfile(ballisticProfile); }

#

firing :
_projectileManager.Fire(muzzleTransform.position, shotDirection, _ballisticProfileId, damage, hitForce, unpinRagdollAmount);

#

ballistic charts

#

to do : MOA system? multipliers to change the trajectory of a profile? extrapolation after the chart ends to continue flight?

#

any suggestions?

urban moss
urban moss
#

Performance Showcase:
https://streamable.com/snzmty

Changes;
Added a MOA value to pass into the Fire() method (1 MOA (Minutes of angle) is equal to a 1 inch spread at 100 yards, 2 inches at 200, etc.)) for semi realistic accuracy.

Added a ExtrapolateData() method to increase the number of entries in the ballistic profile by an amount of entries (tip: when you select a preset you must return to Custom (it will keep the entries) before you can extrapolate)

Added a DensifyBallisticData() method to add interpolated values in-between the entries using a catmull rom spline as to not have a jagged trajectory

Added a multiplier value for drop and velocity that will be passed into Fire(Vector3 position, Vector3 forward, float moa, int profileId, float damage, float hitForce, float velocityMultiplier, float dropMultiplier) , a higher velocity multiplier eg. 1.3 will increase the velocity by 30%, a higher multiplier for drop eg. 2 will increase the drop amount by 100%

Watch "2025-10-09 02-24-04" on Streamable.

▶ Play video
urban moss
#

any suggestions on what to add?

urban moss
small needle
#

BigBootyBallastics 😂 😂

urban moss
#

BBB

#

should i add an option to do the shotgun typa deal i had in the video. so you can just pass in the values?

visual talon
#

This is actually awesome! 😍 it took me about 5 minutes to set up, and is waaaaaaay better than what i had originally

#

I was in the process of making my own, but i was very early on in development (think large spheres shooting from gun muzzle)

i said fk it and used yours to try and its great

#

you couldve 100% put this up on the asset store for like $5

urban moss
#

I gotta polish it up a bit

urban moss
urban moss
#

Small update:

added public method InitializeVisualEffects(SurfaceEffectProfile surfaceEffectProfile, VisualEffect projectileEffects). The visual effects (decals, impacts, projectile vfx) are now declared externally from the manager, and must be passed in to initialize the pools/projectileVFX (you can do this when you register the BallisticProfile). This allows for different types of weapons to use different types of impacts/vfx. The Fire() method has also been updated to include the SurfaceEffectProfile and VisualEffect. (Tip: add your projectile vfx to the prefab with the script to assign it)

Fire(Vector3 position, Vector3 forward, float moa, int profileId, float damage, float hitForce, float velocityMultiplier, float dropMultiplier, SurfaceEffectProfile surfaceEffectProfile, VisualEffect projectileVFX)

added public method FireBurst(Vector3 position, Vector3 forward, int profileId, float damage, float hitForce, float velocityMultiplier, float dropMultiplier, float minSpread, float maxSpread, int projectilesPerShot, SurfaceEffectProfile surfaceEffectProfile, VisualEffect projectileVFX) this takes in all the same things as the normal fire method with exception of an MOA value. It also takes in a min and max spread amount, and a projectilesPerShot value. The spread is calculated as a diameter at 10 meters, eg. a spread of 1f will have a diameter of 1 meter at a distance of 10 meters. Each burst will have a random diameter within the min and max spread.

made some more vfx assets to demo the ability to use more than one. fixed some bugs with the projectile vfx and decals

#

pass in the position and forward vectors? or just pass in a transform and handle the rest internally? 99% of the time if not all the time the z axis will be the firing axis so it seems unnecessary