Turning Things Off : Pace, Brains, Power and Destroy

By LadylexUK (Nov 2014)
Copied from Project Spark.com on Wayback Machine

There are many reasons why you would want a prop or a character to stop moving, or stop existing, or prevent them from being controlled. There are also multiple ways to do this. This tutorial is to explain the role of different Kode tiles, and how you might use them.

Pace

Found in the appearance section of the Kode wheel. This tile is a specialised number variable which controls animation speed.
It can be used in a character brain to speed up or slow down movement.
The default for pace is 1 and can be increased to any number. Pace of 0 means the object/character is frozen.

WHEN [Once]DO [pace][=][2] // If you want this to be the pace throughout

This character will now do everything twice as fast – move, emote. The brain however will still perform at the same speed (30 frames a second), so any timers in the brain will act exactly as before

WHEN[Once] DO [pace][=][0]

This character is frozen into position. The brain is still active however, so any display Kode (such as a health meter) or control Kodes (such as press B to interact) will still operate – only movement controls are affected.

This is useful for creating statues. If you add an emote and put a countdown timer before the pace command you can create statues in interesting poses. Work out how many frames until you get the pose you want.

WHEN [Once] DO [emote][cheer]
WHEN [countdown timer][1][in frames] DO [pace][=][0]

You can also use this kode with the [started to] tile. For example this death animation in a goblin. Notice that not only the goblin freezes in place but also the special effects that accompany the death. If you dont reinstate the pace to normal, the special effect will remain in your world after you have destroyed your goblin.

WHEN [started to][is dead] DO [boolvar: death][equals][true]
WHEN [boolvar:death] DO [pace][=][0]
…WHEN [countdown timer][2] DO[pace][equals][1]
…WHEN [countdown timer][equals][3] DO [destroy][me]

World Pace

In order to change the pace of every object and character in the world you use world pace. It does not require the global tile.
It works exactly the same as pace, but this time it is every object including effects. It does not affect the sky box animations. You can even defy gravity and have objects suspended in mid air.

If you want to have the player access a display screen, so they can no longer see the world around them (such as a menu), and there is a chance they could be attacked while they are doing this, then setting World pace to 0 while accessing the menu would be a good idea.

Brain is active tile

When accessing a shop, or while engaging in dialogue, or a menu, or a cut scene, you will need to “turn off” your player character.
You dont want the controls that are used in your inventory menu to clash with your attacking or movement controls. Also, as only 1 camera should be active at any one time, if you want to introduce a cinematic cut scene you will need to turn off your players camera.

The tile that is used for that is brain is active (yin yang symbol) found in the Brains section of the Kode wheel.

For a cut scene Kode a logic cube like this:

WHEN [started to][detect][Player] DO [objvar:player][=][it]
…WHEN DO [objvar:player][brain is active][=][false]
…WHEN DO [switch page][2]

page 2
You put your camera Kode in here
When the sequence is over add
WHEN[Once] DO [objvar:player][brain is active][=][true]
WHEN DO [destroy][me] – assuming you only want the cut scene to play once

Remember if you turn the player’s brain off, you must turn it back on again afterwards.

You can also turn the brain on and off from the beginning using Edit/Properties/Brain/Brain is Active. Which can be turned on again in Kode.
NOTE: You cannot turn on a brain with Kode in its own brain – it has to come from another brain.

Power

You can program a brain so that nothing will run unless it has power. Power is a specialised boolean variable – it can be either on or off.

WHEN [has power]
…WHEN DO(the rest of your brain Kode)

Power can be transferred from one object to another using a power connector in Edit mode, or you can turn power on with a command like this:

WHEN [interacted] DO [power on]
WHEN [has power]
…WHEN (the rest of your brain Kode).

So although the brain is active, the Kode underneath the [has power] does not run because it is waiting for power. This is very handy for doors and machinery.
Power can also be controlled from Edit/Properties/Brain/Power

Death and Destroy

Killing an object is not quite the same as destroying an object.
If you put in a Kode to kill a goblin, for example, the goblin will go through a death animation and make a deathly moan.It will then be destroyed with a special effect – unless you change its settings (see below).The object is removed from the world completely and any brain Kode it was running will stop.
If you put in Kode to destroy a goblin it will just vanish – no effects. The object is removed from the world completely and any brain Kode it was running will stop.

Edit/Properties/Combat/Health and Defences has various settings around death

Invulnerable: You can attack it but its health is unaffected and it doesnt show any hit reactions
Immortal: You can attack it,its health is affected,it does show hit reactions, but it cannot be killed
Attackable: Turned to off, you cannot attack it.
Destroy after death: Turned to off. The dead character will remain visible in the world as a dead body.

If you set your starting health to 0 the character will dead as soon as it is created. Turn off destroy after death and you have a dead object that you can place in your world like a prop. The brain of the dead object still runs Kode though, so if you also want that to stop you need to use the brain is active = false tiles.

WHEN [started to][is dead] DO [brain is active][=][false]

Comments are closed.

Website Powered by WordPress.com.

Up ↑

%d bloggers like this: