|
Scripted Destruction - Destruction from Event/Damage
|
Uses: This is a template you can use for innumerable
destruction sequences. All you've got to do is figure out the
'ingrediants' and hook them up appropriately. You can use this
for breakable glass, tables, chairs, bottles, crates,
and other stuff, frozen ice sculptures, rocks, columns, doors,
gates, destroyable walls, ceilings, and floors. Just
about anything, in fact.
Respawning/Resetting Items: If, for some reason,
you want these items to 'respawn', you can do it in many ways,
but the easiest would be to:
a) Replace any 'Destroy's with 'Toggle
Hidden' and 'Change
Collision's
b) Hook a delay up to the end of the sequence
c) Hook the end of the delay up to the 'Toggle
Hidden' and 'Change
Collision' so that the items are revealed and are collidable
again.
I have set up a simple test map consisting of a slab of BSP, a
skylight, a playerstart, a skydome, and a directional light.
I will only be using default editor assets which can be found
in the EditorMeshes and EditorMaterials
packages.
I will be using Movers/Interpactors (the terms are interchangeable)
that are sometimes animated through Matinee. If you need to
learn Matinee, I would recommend Hourences'
Tutorial on them as a starting point.
I added the default mesh cube as a static mesh to the map, converted
it to an interpactor, and then made it somewhat thin.
Destruction from an Event or Damage: Destruction
in a level can be set off many ways, but the two most common
are from an Event in a level - for this example a simple trigger,
or from the item taking damage, for example from being shot
by the Player. Since either are used to set off a destruction
sequence, I will make one destruction system, but at the beginning
I'll set up both the trigger and damage event even though they
would not normally be used simultaneously like this.
I'll start with a very simple system, and then I will add some fancy stuff to it.
Let's use the 'Cooking' analogy I outlined in the Applications
Introduction to set this up:
1) What are we making?
A level asset that is detroyed after a player enters a trigger's
radius, or by being shot by the player.
2) Gather the ingredients:
Trigger
Interpactor
Destroy Action
Trigger Touch Event
(Proximity)
3) Put it together. In the level, I've created two walls and
placed the mover between them. Then I placed the trigger in
the middle of the mover and increased its radius.
|
|
On the kismet side of things, I used the trigger to create a
Trigger Touch Event, and then Selected the Interpactor and created
a Take Damage Event based off of it. Finally, I added a Destroy
Action and referenced the mover. I set the take Damage event
to a DamageThreshold of 10, MinDamageAmount of 5, and MaxTriggerCount
of 0. On the Trigger Touch event, I set the MaxTriggerCount
to 1, since we'll only trigger the system once.
|
|
4) Test it. Go in game and test it out. It worked fine for me.
5) Refine it. First, think about the collison and lighting and
get those fixed. When it dissappears, does its shadow go away?
Then consider any potential issues. Can the player 'break' the
system as it is? Once you've settled the issues, feel free to
iterate on the system.
For example, after #6, we'll go nuts on this one because, as
it is now, it's pretty unimpressive.
6) Adjust it for Single/Multiplayer. As you may have read in
the SinglePlayer/Co-op/MultiPlayer
section, there are many considerations to take into account
for whichever system you're setting this up for. The system
as it stands doesn't really need anything changed. It's simple,
it works, and it doesn't seem breakable at this time.
Alright, let's dress it up and make it fun.
Now, with what I'm about to do, please remember that you can take each piece of it and add it to a system or remove it depending on what you want.
Alright so - let's do our cooking analogy again:
1) What are we making?
We're going to make a destructable object that contains two
levels of destruction. When it partially destructs, it should
activate an emitter to hide the mesh swap we'll do and make
an appropriate noise. When it fully destructs, it will explode
with enough force to damage the player/AI if they are in range.
It will eject impulsed debris, activate emitters to hide the
mesh swap, and will sound like an explosion. :) You ready?
2) Gather the ingredients:
2 Take Damage Events
4 Toggle Actions
2 Toggle Hidden
Actions
3 Destroy Actions
2 PlaySound
Actions
Delay Action
CauseDamageRadial Action
Mover (Whole)
Mver(Partial)
KActor (Debris)
2 Emitters
RB_Thruster
3) Put it together:
First, I'll position the 'Whole' mover. Then I'll place the
'Partial' mover inside it, open its properties and tick the
'Hidden' checkbox to hide it in game. Then I'll place the KActor
kind of 'floating' in the middle of the 'Partial' mover since
that will be its visual origin and I'll hide it like I did the
'Partial' mover. Then I'll place one emitter in the middle of
the 'Whole' mover to mask its destroy. Likewise, I'll place
the second emitter in the middle of the 'Partial' mover to mask
its destruction. Then I'll grab both emitters and turn their
'AutoActivate' off in their properties. Then I'll go into the
Actor browser and grab and place an RB_Thruster Actor. These
need a manual turn off so we'll need to add that to the Kismet.
I'll set its Thrust strength to 50, and then I'll Attach
it to the KActor through its properties.
*Note: Although KActors and RB_Thrusters and RB_RadialImpulses
can be used to throw KActors about, KActors, from being movers
with physics, are fairly expensive. If you need to create debris,
I would highly recommend using mesh emitters instead simply
for performance reasons.
|
|
On the Kismet side, first I'll set up the destruction of the
'Whole' mover. The partial destruction phase. First, I'll create
the TakeDamage Event on the Whole mover. The MaxTriggerCount
is set to 0, and I arbitrarily set the DamageThreshold to 50.
When it fires, We need to destroy the Whole Mover, Toggle on
the emitter, play a sound, and unhide the partial mover. Since
the partial mover is only hidden, in theory, if it stuck out
from the whole mover, it could be damaged before we were ready
for that. So I'll Create the partial mover's take damage event,
and uncheck 'bEnabled' so that the Event is 'off' until I tell
it to be on. To do that, I'll toggle the event on once the whole
mover's take damage event is fired.
Now, for the partial mover, we need to finish the destruction.
We'll need to destroy the partial mover, unhide the KActor and
activate the RB_Thruster, fire off the emitter and associated
sound, and then, after a delay, turn off the RB_Thruster, and
destroy the KActor so it doesn't get in anyone's way during
gameplay. On the partial mover's take damage event, I have set
the DamageThreshold and MaxTrigger count the same as the previous
TakeDamage Event.
|
|
4) Test it. Go in game and test it out. It worked fine for me.
5) Refine it. First, think about the collison and lighting and
get those fixed. When it dissappears, does its shadow go away?
Then consider any potential issues. Can the player 'break' the
system as it is? Once you've settled the issues, feel free to
iterate on the system.
6) Adjust it for Single/Multiplayer. As you may have read in
the SinglePlayer/Co-op/MultiPlayer
section, there are many considerations to take into account
for whichever system you're setting this up for. The system
as it stands doesn't really need anything changed. It works,
and it doesn't seem breakable at this time. There is one major
concern with the system if you're working with AI, however.
If you need AI to path around it, that's easy. But if you need
AI to path through the location where it used to be after it's
destroyed, that's another issue. In theory - and I suspect this
will vary greatly depending on what game/engine version you
use, you can set up some toggles pointed to nearby pathnodes
to 'activate/deactivate' them, by also working with their 'bBlocked'
property. However, I would reccomend experiementing heavily
with this before attempting to utilize it.
*Note: Although I used two individual interpactors for the two
destruction phases, it is possible to use one. In this case,
you can use a 'Set
StaticMesh' Action to perform the 'switch' to the second
phase. However, depending on the pivot locatins of the meshes
involved, this can sometimes mean that the mesh changes place
when it switches. To set it up, you would still use two damage
events - the first would fire after a certain amount of damage,
and the second would fire after a higher amount. The first destroy
action in the system would be replaced by the Set StaticMesh.
This is actually a 'cheaper' method as you would be using less
actors overall, but if the pivot of the two meshes is a problem,
the method described is a satisfactory work-around.
I think that's about it. Now you should have a decent
foundation on how to create destructible sequences that you
can adapt to doors, barrels, small barriers, multi-stage destruction
- just about anything.
|
|
|
|
|
|