Car Explosions: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
(36 intermediate revisions by 14 users not shown)
Line 1: Line 1:
''by Mxthe''
==Introduction==
== To Begin ==


This tutorial will explain how to create an explosion effect for an automobile. You will require basic knowledge of the [[Valve Hammer Editor]]. This tutorial is not hard to follow and is an extended function of [[trigger_push]].


In this tutorial i'm going to explain how to blow cars at 10 meters with smoke, explosions and nice effects.
==The Car==
You need to have the basic knowledge of the hammer.
This tutorial is not hard to follow, it is so easy that I figured it out as soon as I discovered the [[Trigger Push]]


----
To start, create a [[prop_physics_override]] with the following settings.


== The Car ==
* '''Name:''' Car1
* '''World Model:''' (In the prop_vehicles folder, choose a car with a physic model.)
* '''MinDamageToHurt:''' 90 (explained later)


Lets start, create a [[prop_physics_override]]
Once the vehicle is created, it must be placed above the ground level.


Name : Car1
In order to add more realism and interactivity, a fuel tank should be placed close to the car that will explode if shot.


World Model : (In the prop_vehicles folder, choose a car with a physic model.)
Create a brush on the car wherever the fuel tank may be located, choose a good texture for a fuel tank and make the fuel tank a [[func_breakable]].


MinDamageToHurt : 90 (ill explain later)
* '''Name:''' FuelTankCar1
* '''Parent:''' Car1
* '''MaterialType:''' Metal


There you have your car, put it at 10 units above the ground.
For design purposes, the fuel tank may be a cylinder or another similar shape.


To do more realism and more fun, we are going to put a fuel tank that blows the car if we shoot it.
==The Effects==


Create a brush on the car where you want the fuel tank, choose a good texture for a fuel tank and make the fuel tank [[func_breakable]]
Create five [[env_explosion]] entities and place them at five points around the vehicle, like on a die, i.e. the sides, front, back, and bottom.


Name : FuelTankCar1
* '''Name:''' ExplosionCar1
* '''Parent:''' Car1
* '''Magnitude:''' 100


Parent : Car1
Then create an [[env_physexplosion]] entity at the center of the vehicle.


MaterialType : Metal
* '''Name:''' PhysExplosionCar1
* '''Parent:''' Car1
* '''Magnitude:''' 500


----
Create an [[env_smokestack]] entity and place it where the smoke will be emitted.


== The Effects ==
* '''Name:''' SmokeCar1
* '''Parent:''' Car1
* '''Color:''' You may choose any color you wish.


Now the explosions and smoke.
==The Thrust==


Create 5 [[env_explosion]] and put them at the 5 points of the car, like on a dice.
Though there are several explosion entities in place surrounding the car, it is still not enough to lift the car due to its weight.  


Name : ExplosionCar1
Create a brush at the center of the vehicle and make it large enough to encompass the top side while starting from the bottom. Apply the trigger texture and TieToEntity [[trigger_push]]. The car will fly as high as the trigger is configured.


Parent : Car1
* '''Name:''' PushCar1
* '''Parent:''' Car1
* '''PushDirection:''' Up
* '''StartDisabled:''' Yes
* '''Speed of push:''' 1500
* '''Flags:''' OnlyOnce, Physics objects, Physics debris, Pushables


Magnitude : 100
{{Tip|Make sure the Client flag is not enabled, or consider using a [[filter]]}}


Then create an [[env_physexplosion]] at the center of the car.
==The Outputs==


Name : PhysExplosionCar1
At this point, the explosion effect will not work. The outputs of the car entity must now be configured in order for this to happen.
 
Parent : Car1
 
Magnitude : 500
 
Now, create an [[env_smokestack]] where you want the smoke to be, the engine is the better place :)
 
Name : SmokeCar1
 
Parent : Car1
 
Color : Choose it :P
 
----
 
== The Fly ==
 
We got explosions, physexplosions but not enough to make a car fly!It is too heavy!
So, create a brush at the center of your car, make it big enough to cover all the top of it, and it must start from the bottom of the car.
Make it the trigger texture and TieToEntity [[Trigger Push]]
Now make the trigger go as high as you want your car to fly.
 
Name : PushCar1
 
Parent : Car1
 
PushDirection : Up
 
StartDisabled : Yes
 
Speed : 1500
 
Flags :
 
OnlyOnce
 
Physics
 
Pushables
 
Okay thats it for the trigger push, check that the Client flag is NOT enabled.
 
 
----
 
== The Outputs ==
 
OKay, we got this mess, but nothing  works!
So we must create the outputs!


First, go in the car's properties.
First, go in the car's properties.


Remember the MinDamageToHurt? It makes the car ignore all damage less than 90.
MinDamageToHurt allows entities to ignore all damage less than a specified amount and 90 is best for explosions like grenades and rockets.
And 90 is the perfect amout for grenades, rocket but none other gun!
 
So, in the Outputs of the car, put :
 
OnHealthChanged : ExplosionCar1      Explode        OnlyOnce : Yes
 
OnHealthChanged : PhysExplosionCar1  Explode        OnlyOnce : Yes


OnHealthChanged : PushCar1            ClearParent    OnlyOnce : Yes
The outputs of the car entity should be as followed:


OnHealthChanged : PushCar1           Enable         OnlyOnce : Yes
{| class=standard-table
|+'''Car Outputs'''
!  || My Output || Target Entity || Via This Input || Parameter || Delay || Only Once
|-
| {{IO11}} || OnHealthChanged || ExplosionCar1 || Explode || <none> || 0.00 || Yes
|-
| {{IO11}} || OnHealthChanged || PhysExplosionCar1 || Explode || <none> || 0.00 || Yes
|-
| {{IO11}} || OnHealthChanged || PushCar1 || ClearParent || <none> || 0.00 || Yes
|-
| {{IO11}} || OnHealthChanged || PushCar1 || Enable || <none> || 0.00 || Yes
|-
| {{IO11}} || OnHealthChanged || SmokeCar1 || TurnOn || <none> || 0.00 || Yes
|-
| {{IO11}} || OnHealthChanged || FuelTankCar1 || Break || <none> || 0.00 || Yes
|}


OnHealthChanged : SmokeCar1          TurnOn        OnlyOnce : Yes
The car will now ignore damage less than 90 and therefore, when a damage amount above 90 is applied to the car, the explosions ignite, the smoke starts, the fuel tank is destroyed, and the [[trigger_push]] entity loses its parents. If it is still parented to car1, the entity would pursue the car up in an infinite cycle.


OnHealthChanged : FuelTankCar1        Break          OnlyOnce : Yes


Okay i'll explain what we just did.
To destroy the Fuel Tank, the outputs of the car can be reused with OnHealthChanged changed to OnBreak to destroy it, like so:
We made that the car ignore damage less than 90, so if a damage ABOVE 90 is apllied to the car, the explosions blow, the smoke to start, the fuel tank to be destroyed and the trigger push forget his parents, because if we leave him parented to car1, the trigger would follow the car as long as it goes up and it would never end.


{| class=standard-table
|+'''Fuel Tank Outputs'''
!  || My Output || Target Entity || Via This Input || Parameter || Delay || Only Once
|-
| {{IO11}} || OnBreak || ExplosionCar1 || Explode || <none> || 0.00 || Yes
|-
| {{IO11}} || OnBreak || PhysExplosionCar1 || Explode || <none> || 0.00 || Yes
|-
| {{IO11}} || OnBreak || PushCar1 || ClearParent || <none> || 0.00 || Yes
|-
| {{IO11}} || OnBreak || PushCar1 || Enable || <none> || 0.00 || Yes
|-
| {{IO11}} || OnBreak || SmokeCar1 || TurnOn || <none> || 0.00 || Yes
|}


Now the car is done, what about the Fuel Tank?
The car outputs are not disabled by the fuel tank explosion such that the explosions would inflict damage to the car and cause a second explosion for added effect.
Well just copy the outputs of the car and change the OnHealthChanged to OnBreak, like this :


OnBreak : ExplosionCar1      Explode        OnlyOnce : Yes
The map can now be compiled and tested.


OnBreak : PhysExplosionCar1  Explode        OnlyOnce : Yes
==Other Suggestions==


OnBreak : PushCar1            ClearParent    OnlyOnce : Yes
'''Spinning Car/ Car flips in air'''


OnBreak : PushCar1            Enable        OnlyOnce : Yes
If you place a brush textured with the tools/toolsinvisible texture, and place it closely above your car(as close as you can get while not touching, keep in mind the car will ricochet off of this), when the car 'explodes' and is thrusted upwards,
it will collide with the brush and spin off of it. '''Note:''' The brush should not cover the entire vehicle, it should only cover a small portion. If you cover too much, the car will not be able to get off of the ground.


OnBreak : SmokeCar1          TurnOn        OnlyOnce : Yes


Here for the Fuel Tank!
'''Fallout-esque explosion'''


You may wonder why I didnt put an output to disable the car outputs in case the fuel tank blows!
One may also trigger smoke before the explosion, giving all explosions and pushes a delay (say, 2-3 seconds), and afterwards spawning more smoke and fire.
Because the explosions inflict the damage to the car, so it happens TWICE :-D
Now Compile the map and test it, watchout where the car falls :P




----


[[Category:LevelDesign]]
It is suggested that all of the previous is tested before you drop the final version into your mod (if this is your first time).
[[Category:Level Design]]
[[Category:Tutorials]]
[[Category:Physics]]

Latest revision as of 00:28, 13 June 2022

Introduction

This tutorial will explain how to create an explosion effect for an automobile. You will require basic knowledge of the Valve Hammer Editor. This tutorial is not hard to follow and is an extended function of trigger_push.

The Car

To start, create a prop_physics_override with the following settings.

  • Name: Car1
  • World Model: (In the prop_vehicles folder, choose a car with a physic model.)
  • MinDamageToHurt: 90 (explained later)

Once the vehicle is created, it must be placed above the ground level.

In order to add more realism and interactivity, a fuel tank should be placed close to the car that will explode if shot.

Create a brush on the car wherever the fuel tank may be located, choose a good texture for a fuel tank and make the fuel tank a func_breakable.

  • Name: FuelTankCar1
  • Parent: Car1
  • MaterialType: Metal

For design purposes, the fuel tank may be a cylinder or another similar shape.

The Effects

Create five env_explosion entities and place them at five points around the vehicle, like on a die, i.e. the sides, front, back, and bottom.

  • Name: ExplosionCar1
  • Parent: Car1
  • Magnitude: 100

Then create an env_physexplosion entity at the center of the vehicle.

  • Name: PhysExplosionCar1
  • Parent: Car1
  • Magnitude: 500

Create an env_smokestack entity and place it where the smoke will be emitted.

  • Name: SmokeCar1
  • Parent: Car1
  • Color: You may choose any color you wish.

The Thrust

Though there are several explosion entities in place surrounding the car, it is still not enough to lift the car due to its weight.

Create a brush at the center of the vehicle and make it large enough to encompass the top side while starting from the bottom. Apply the trigger texture and TieToEntity trigger_push. The car will fly as high as the trigger is configured.

  • Name: PushCar1
  • Parent: Car1
  • PushDirection: Up
  • StartDisabled: Yes
  • Speed of push: 1500
  • Flags: OnlyOnce, Physics objects, Physics debris, Pushables
Tip.pngTip:Make sure the Client flag is not enabled, or consider using a filter

The Outputs

At this point, the explosion effect will not work. The outputs of the car entity must now be configured in order for this to happen.

First, go in the car's properties.

MinDamageToHurt allows entities to ignore all damage less than a specified amount and 90 is best for explosions like grenades and rockets.

The outputs of the car entity should be as followed:

Car Outputs
My Output Target Entity Via This Input Parameter Delay Only Once
Entity-output-icon.png OnHealthChanged ExplosionCar1 Explode <none> 0.00 Yes
Entity-output-icon.png OnHealthChanged PhysExplosionCar1 Explode <none> 0.00 Yes
Entity-output-icon.png OnHealthChanged PushCar1 ClearParent <none> 0.00 Yes
Entity-output-icon.png OnHealthChanged PushCar1 Enable <none> 0.00 Yes
Entity-output-icon.png OnHealthChanged SmokeCar1 TurnOn <none> 0.00 Yes
Entity-output-icon.png OnHealthChanged FuelTankCar1 Break <none> 0.00 Yes

The car will now ignore damage less than 90 and therefore, when a damage amount above 90 is applied to the car, the explosions ignite, the smoke starts, the fuel tank is destroyed, and the trigger_push entity loses its parents. If it is still parented to car1, the entity would pursue the car up in an infinite cycle.


To destroy the Fuel Tank, the outputs of the car can be reused with OnHealthChanged changed to OnBreak to destroy it, like so:

Fuel Tank Outputs
My Output Target Entity Via This Input Parameter Delay Only Once
Entity-output-icon.png OnBreak ExplosionCar1 Explode <none> 0.00 Yes
Entity-output-icon.png OnBreak PhysExplosionCar1 Explode <none> 0.00 Yes
Entity-output-icon.png OnBreak PushCar1 ClearParent <none> 0.00 Yes
Entity-output-icon.png OnBreak PushCar1 Enable <none> 0.00 Yes
Entity-output-icon.png OnBreak SmokeCar1 TurnOn <none> 0.00 Yes

The car outputs are not disabled by the fuel tank explosion such that the explosions would inflict damage to the car and cause a second explosion for added effect.

The map can now be compiled and tested.

Other Suggestions

Spinning Car/ Car flips in air

If you place a brush textured with the tools/toolsinvisible texture, and place it closely above your car(as close as you can get while not touching, keep in mind the car will ricochet off of this), when the car 'explodes' and is thrusted upwards, it will collide with the brush and spin off of it. Note: The brush should not cover the entire vehicle, it should only cover a small portion. If you cover too much, the car will not be able to get off of the ground.


Fallout-esque explosion

One may also trigger smoke before the explosion, giving all explosions and pushes a delay (say, 2-3 seconds), and afterwards spawning more smoke and fire.


It is suggested that all of the previous is tested before you drop the final version into your mod (if this is your first time).