How to make a projectile out of anything

This if for tutorials and information for the community to use for great works.
Keep them organized now!..
Post Reply
User avatar
CaptainPoopface
Posts: 714
Joined: Sat Feb 16, 2008 5:47 am

How to make a projectile out of anything

Post by CaptainPoopface »

Use this technique to do any of the following:
- Fire a working, drivable vehicle from a gun
- Shoot working weapons/ammo, blocs with full phmo and coll, bipeds, etc., with ballistic properties instead of the old "fall out of the gun" proj swap
- Hurl any object, such as a truck, instead of a grenade
- Toss multiple, different grenades in a single throw
- Give different throwing velocities to your two grenade types
- Get a splatter kill for crushing your enemies with a high-velocity phmo impact
- And other such chicanery

First, add the chunk for a bloc in the attachments reflexive of an effect (Out of habit, I always use the bumper from the warthog bumper_destroyed effect).

Image

Swap this bloc to anything you want to "shoot."

Go to the Parts reflexive and find the part that is your object.

Image

"Velocity Bound" and "...To" are the min and max velocity of your object. When it is spawned, it will have a velocity chosen at random between those two values. Note that this is different from a projectile's initial and final velocity - an object spawned by an effect does not accelerate. Set these two values the same if you want the object to consistently travel at the same velocity each time it is spawned.

"Velocity Cone Angle" is intended for the motion of particles from an impact. My understanding is that it describes an angle of deflection from the vector indicated by the marker. For our purposes, this is undesirable. Set it to 0.

"Angular Velocity Bound" and "...To" are the min and max rotational speed of the object. My guess is they are in radians per second. If you set these to 0, the object will spawn in exactly the same orientation each time, and it will maintain that orientation as it flies. If you set them to nonzero values, the object will rotate as it moves through space. The rotation axis is quasi-random, so unfortunately you cannot use these values to make your spinning ninja stars or throwing axes. Angular velocity gives some objects a little more character or variation when thrown, so just think of it that way.

Lastly are the "Radius Modifier" fields. I don't know what radius they modify. Leave them at 1 or set them to 0. It doesn't seem to matter for this application.

Using the effect with a weapon

If you have added the chunk for your object in a firing effect, then it will now act as if it is being fired from the gun, as long as it has the same marker (for most guns, the firing effect happens at a marker called "primary_trigger"). Be sure the actual projectile of the gun does not interfere with the object you are spawning from the firing effect: Null all the dependencies of the projectile, but do not null the projectile reference from the weapon. IIRC, if you null the reference, the firing effect won't happen.

If you are spawning relatively large objects from a firing effect, be careful. If the phmo of the object intersects your body or the BSP when spawned, you will be violently pushed away from it, or crushed to death if the object is heavy enough. If the object has health, such as an explosive box, then it will detonate and kill you when it spawns. The firing effect method is best used for small objects. Otherwise, try...

Using the effect with a grenade

This is a good way to put a little bit of distance between yourself and the object before it spawns, so that it does not kill you. Select the detonation effect of a grenade to spawn your object. I like to use the frag grenade's airborne_detonation. In the meta editor, change the marker(s) to "forward." To change a marker name, click the dropdown, select the blank space at the top, type the new marker name, click the dropdown again, and select the marker with exactly that name. Sometimes there are multiple markers that include your marker name in them. Ignore these, select the "forward" marker from the list, then save. I'm not sure why all that hassle is necessary, but it is.

Set the values for the object's velocity and angular velocity as described above. Make this spawning grenade the projectile for your gun or your throwing grenade substitute in the matg. You will have to experiment with the detonation time and velocity of the grenade to get the most realistic results. When firing from a gun, I set the detonation time to about 0.1 and the velocity to 5. For a grenade, the throwing animation means you have to wait a little longer - try 0.3 with a velocity of 8. Null the shaders and effects of the spawning grenade, and experiment until it looks best. It won't look quite as natural as a real grenade toss, but it is functionally the same. One trick you can try is swap the model for your spawning grenade to the actual object spawned, but results are mixed depending on what object you use. Finally, some objects just are not really meant to be thrown/fired. I could not figure out how to throw a bus without either getting immediately crushed to death by it, or having such a long spawn delay that it looked awful.

A final note about spawned objects: After about 15-20 seconds, if an object is not interacted with (phmo / coll), it disappears. If you are driving in a vehicle and you go 15 seconds without working the steering, the vehicle will vanish and you will immediately respawn.
User avatar
Aumaan Anubis
Staff
Posts: 1812
Joined: Thu Dec 13, 2007 12:18 am
Contact:

Re: How to make a projectile out of anything

Post by Aumaan Anubis »

Moved to Tutorials.
Post Reply