## luigi123

### Luigi joined Jul 22, 2010

This member has provided no bio about themself...

Kismet Basics - Variables

Posted by on

PROTIP: Click on the images!

Hey guys =D

Today I'm not gonna make progress on the posts about the SCP game. Instead I'm going to talk about variables in Kismet. Because I use a lot of them in the next part.

If you know the first bit about programming and logic in general, you probably know what a variable is, but in case you don't, here are some simple definitions:

1. Something that varies in value.
2. A temporary storage place used in computer applications during calculation.

In kismet, variables are represented by little balls, and there are 6 different types of them, as you can see below:

In case you can't read my beautiful hand writing, the names are (from left to right): Float, Vector, Boolean, Int, String and Object.

Each one has a different color (yay \o/) and stores a different type of value. Below you can see me trying to make a table with all the different color, names and type of storage

Float Dark Blue non-exact numbers, like 3.141592
Vector Brown X, Y and Z coordinates
Boolean Red True / False
Int Light Blue Exact numbers, like 215
String Green Text i.e. "Hello World"
Object Pink Objects inside the level, Player included.

A variable can be either read or written by Kismet, and each one of those two functions has a different representation on Kismet.

When a Kismet box is gonna write a value to a variable, it shows a little arrow connecting the box to the variable.

When a Kismet box is gonna read a variable, you can see a little box connecting the main box to the variable. Below you can see an image with these two examples.

As you can see above, when you start the level, that light is going to be turned on, and ONLY that light. If variables didn't exist in Kismet, every light in the level would be turned on.

And as you can see above, there is a little arrow connecting the condition "Trigger_0 Touch" to the "???" variable.

But what does "???" mean? That is an undefined object variable. You know it's an object variable because of the color (pink). But an object variable must always point to an object, right? Well... no.
As you can see, that one is undefined; this means it has no real value FOR NOW. When someone (let's say a player named "John") touches the object Trigger_0, the undefined "???" variable will become the variable "Player John". It grabs the name of whoever touched the Trigger and writes it down on that variable.

You might be asking yourself right now why would that be ever useful? Well, I've got an example for ya.

Boom.

As you can see, the system above will grab the name of the player who touches the variable, write it down on an undefined one, and then heal him for 100 health, and only him. If the variable didn't exist, once someone touches that trigger, everyone inside the game would be healed.

There you go, now you know how to make a working healing point in Kismet.

But that's for an object variable. There are 6 different types of them. Obviously I won't cover all of them in great detail.

What you must know is that you can do all kinds of stuff with variables, below some examples:

On this example, when the player touches "Trigger_0", it verifies a bool variable called "WallHit" (which is false by default). And if WallHit and the Result variable from the Compare Bool box (True) doesn't match, a message will be displayed (You didn't hit the wall).

To make WallHit and the result variable match, you must turn WallHit into True, and as you can see there, when an even called "Hit Wall" happens, it's gonna grab a True value, and write it on the "WallHit" variable. So now "WallHit" = True.

All you'd have to do now is touch that trigger again, Kismet is gonna verify the "WallHit" variable, see that it matches the other one, and send a "WIIIIINNNNN" message.

That was complicated.

Well, as I said, you can do a lot of stuff with variables, below some examples:

When the event "Whatever" happens, it will add those two values, write the result in a new variable, and show it on the screen through a log.

You can also subtract, divide, multiply, etc... Also you can do all that with Int variables too.

In this case, the system is gonna compare the two variables, and if they are equal, it's gonna print a message on the screen through a log. In this case, nothing is gonna happen, because 1 is different from 4, and nothing is connected to the B > A connector.

Please note that you can do a bunch more with variables, this is just a very brief introduction. I suggest you just open UDK and try to work a system out. Always helps =D

I think this will be it for this blog post. If you have any questions, feel free to ask them in the comments.

My next blog post also won't be about the SCP game. It's about visuals in general, so, expect that in a not-very-near future.

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Profile
Brazil ðŸ‡§ðŸ‡·
Male
Blog