|
Prologue - A Simple Mover
|
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.
*Note: I will start with a simple system, and then I will complicate it.
Let's go through the 'cooking' steps one by one:
1) What am I making?
I am going to demonstrate a trigger touch event on a mover.
2) What are my ingredients?
I need my level ingredients: a trigger, and a static mesh cube.
So I add them to the world.
|
|
Now I need my Kismet ingredients:
I am going to select the trigger, switch to kismet, and create
a Trigger Touch event.
|
|
I am going to select the cube, right click on it, Convert->
to mover/interpactor. Then I will select the new mover/cube
go to kismet, and create an object variable referencing the
cube.
|
|
Last, I'll create a matinee.
|
|
3) Put it together:
First, I matineed the Cube: I created a new group and named
it 'Cube' to represent the object moving and connected the cube's
object reference to the 'Cube' output. Then I created a movement
track under the 'Cube' group. I keyframed the cube rising into
the air: one at the beginning for its 'resting' state, and one
at 5 sec. to represent it's 'open' state.
Then I hooked the 'Touch' event on the trigger to the 'Play'
On the matinee.
|
|
4) Test It:
What happens when we test it? If you hit the 'Play In Editor'
(or PIE) button:
then the level should start up, a player will spawn, and you'll see the cube resting on the ground. Walk towards the trigger, and it should rise up into the air and stop.
*Note: If for some reason the mover/interpactor does not move
check that it's set to 'interpolating'. Open the mover's properties,
expand down the 'Movement' section, and under 'Physics', select
'PHYS_Interpolating' from the drop-down list.
5) Refine it:
Well, now that we know it works, what else do we want to do to it? I'll cover several different properties available to us, and then decide on 1 function.
a) Collision and Lighting.
By default, a mover's collision is turned off. Depending on
your requirements, youll need to change the collision settings
to what you need. You'll also need to adjust the lighting properties,
or the properties of the lights around the mover. Since an interpactor
is a dynamic object, you'll need to light it dynamically. Both
collision and lighting are beyond the scope of this tutorial
so they will not be covered in depth here.
b) After a random amount of time, make it go back down.
We'll simple add a delay hooked up to a randomized float on
the 'completed' of the matinee, and then route the signal into
the 'reverse' of the matinee.
|
|
c) When the player leaves the trigger, lower the cube.
Right now, the trigger can only fire once, it's radius is very
small, and the matinee can only raise the cube to the top. Change
the 'MaxTriggerCount' to 2 - 1 for the Touch event, and 1 for
the Untouch event. Connect the 'Untouch' event to the reverse
on the matinee. Now, the trigger's radius is very small. To
see the radius, hit 'c' which toggles on and off the collision
view in any vieport. Open up the trigger's properties, expand
down 'Trigger' and then expand down 'Cylinder Component' until
you see the 'Collision Height' and 'Collision Radius' settings.
Increase the number here so that the player can reach and stand
inside the radius.
Now test it. Move the player inside the trigger and stop. When
the cube has raised up and stopped, leave the trigger's radius
and it will descend again.
|
|
d) Trigger the system over and over again.
If you unhook the 'untouch' event, and permit the cube to rise
to the top before re-triggering the trigger, you'll notice it
doesn't work. This is because whenever you hit the trigger again,
the matinee recevies the 'play' command, so it tries to play
the matinee from where the current time is. If the current time
is at the end, there is no more to play. To resolve this, select
the matinee in kismet, and in its properties check the box next
to 'rewind on play'. Now, after the matinee is completed, if
you hit the trigger again, it will rewind, and then play again.
e) Trigger the system over and over again with the untouch.
Using the same touch/untouch system as in set 'c', simply set
the 'MaxTriggerCount' in the event to 0. When you test it, you'll
notice that if you step out of the trigger radius while the
cube is rising, it will start to reverse and descend.
f) Move more than one object.
Say this mover was a lift, and there was a box sitting on the
lift. Wuld you have to matinee the box as well? You could, and
several items matineed together could be interesting, but if
it's just another item that's going to be moving in tandem with
the mover, then there's no need to complicate the matinee with
more info. There are two methods - both equally valid - to attach
a seperate asset to a mover. The restriction is that what you
are attaching must also be a mover.
I'm going to duplicate, and shrink the cube I have, and place
it on top of the main Cube. Now, you could do this in Kismet,
but that would be inefficient for this system so I will not.
For more info on how to do this in Kismet, check the 'Attach
To Actor' page.
For the non-Kismet method, select the small cube, open its properties,
and expand down the 'Attachment' section. Click the lock icon
in the upper left corner of the window to 'lock' the window
open. Now, in the perspective window, select the large cube.
The properties window will stay on the small cube because you've
locked it. Now, in the properties window, select the 'base'
line, and hit the green arrow to input the large cube into that
field. The large cube is the 'base'. Finally, select 'Hard Attach'
and close the window.
Now, when you trigger the cube, the small cube will ride up
on top of it.
If the small cube was to move around on top of the large cube
while the large cube moved, then you would add a new group and
movement track to the matinee and keyframe the small cube's
movement seperately.
|
|
g) Two triggers to fire the same sequence.
If you have two seperate triggers that can fire the same sequence,
they can easily be set to accomplish the same thing, but you'll
need to consider what would happen if they were both set off
either at the same time, or seperately.
In my greymap, I've moved the Cube back, added a BSP wall, moved
the trigger to one side of the wall, and added a trigger volume
to the other side of the wall. Triggers and trigger volumes
are interchangable, you'd select the one you want to use simply
based on the collision shape you need. Now, I'm going to duplicate
the trigger event I have in kismet, then right click on it and
assign the trigger volume to it.
|
|
Now I just connect the two touch events to the Play of the matinee.
Now, if the player touches either the trigger, or the trigger
volume, the cube will rise up.
The down side to this system is that if I hit the trigger, the sequence will play, but if I then go and hit the trigger volume, it will play again. And this may not be what I want to happen.
|
|
h) Two triggers fire the same sequence, but one will disable the other.
There are several ways to accomplish this. You could set up
a system with a gate, or booleans, or counters, but that could
be overcomplicating things depending what else is going on.
So I'm going to choose a toggle for this simple system. The
thing to remember about toggles and events is that using a toggle
to shut of a trigger event only shuts off the event - it does
not shut off the trigger. So you could have other events based
on the same trigger still fire off, with this one event toggled
off.
After adding the toggle, I connect the touch events to the 'off'
section, and then tell the toggle what to turn off by connecting
the red output to the two trigger events. Now, when either trigger
fires, it will shut both triggers off. I could not, however,
turn the triggers back on by using their untouch event to toggle
them back on, because the triggers are turned off. I would need
to use another method, gates & delays, booleans, something,
to control their on/off.
|
|
6) Adjust the system for singleplayer/multiplayer.
I cover this more in depth elsewhere,
but you'll always need to take this into account when working
with triggers and events. However, here are some leading questions
to aske yourself:
Singleplayer: Is the player a dedicated class? Are
enemy NPCs also considered 'players'? These questions will help
you decide on whether to check/uncheck the 'playersonly' checkbox
in the trigger's properties. Sometimes you'll want the player,
but not NPCs to trigger events, yet other times you'll want
both to. You might also need to tweak the class settings the
trigger can detect in its properties.
Multiplayer: What happens when one player enters the
trigger? What happens when two enter? What happens when two
enter, but one leaves and one stays? Or if they both leave?
You'll need to build in safeguards for all these eventualities
and more when setting up Kismet for Multiplayer maps.
I could go on iterating more possible systems to the end of the alphabet and beyond, but I believe these will get you to a certian base level from which you can dive off on your own. Happy scripting!
|
|
|
|
|
|