Create position and orientation

In this tutorial we will look at the create tile to understand how to create your objects where you want them, and in the correct orientation.

 

Default settings

This line of kode in A Woodland villager brain, in a Start from scratch world.

WHEN [once] DO [create][Rock arrrowhead]

Will create a rock arrowhead pointing South, 1 meter in front of your player at waist height. The object is defaulted as a fixed object.

Do the same with a tumbling object, or character and the object will appear at the same position and fall to the ground.

Changing the facing position

We will assume for the minute that you are happy with the place the object appears, but want it to be turned to face a new direction. You have a few options

1.Create facing another object in the world

If you want your object to be created facing an object that already exists in the world then use this kode

WHEN [once] DO [create][Rock arrowhead][towards][IWP:door]

You need to be aware that if you are creating a character with this kode (or any of the following kodes that change the orientation of the character), they will always orientate towards your object, often leaning at weird angles, especially if the object is in the air for example. To stop this, add this line of kode to the character brain.

WHEN [once] DO [down][=][World down]

2. Create facing a cardinal compass direction.

You would think this would work:

WHEN [once] DO [create][Rock arrowhead][towards][east]

Except this will point your arrowhead east and down at the ground. So instead use this kode

WHEN [once] DO [objvar:new][=][create][Rock arrowhead]
…WHEN DO [objvar:new][forward][=][east]

3. Create facing a specific direction when there is no object to face.

If you do not have an object in your world you could specify a spot and reference that.

Take a logic cube with this in its brain

WHEN DO [display][position][screen top center]

Put your cube where you would like the object to face. Test. Note down the numbers.

Create a vector like this; the first number is east, the second is world up, the third is north

WHEN DO [vectorvar:face][=][east][multiplied by][9.7][+][world up][multiplied by][13][+][north][X][-17.5]
WHEN [once] DO [create][Rock arrowhead][toward][vectorvar:face]

Test. Your object should face your logic cube. You can now safely delete the cube, as you know the coordinates.

4. Creating an object upside down

(really only suitable for static objects, though it is interesting to see characters walking upside down)

WHEN [once] DO [objvar:new][=][create][Castle tower base]
…WHEN DO [objvar:new][position][y][=][position][y][+][objvar:new][height] 1
…WHEN DO [objvar:new][up][=][World down]

You can also combine that with a facing direction.

Changing the creation position

Now you want the object to be created somewhere different. You can specify the position as that of another object (normally a logic cube), a vector, an offset of a position on the creator, or a combination.

1. Creating at the same position as the current object (normally invisible and non collidable logic cubes)

You do this for respawn checkpoints or spawning sites.

WHEN [once] DO [create][goblin][at position][position]

2. Creating at the same position of another object

WHEN [once] DO [create][goblin][at position][IWP:logic cube][position]

3. Create at a vector position (same method as for towards vectors)

WHEN [once] DO [create][goblin][at position][vectorvar:my spawn point]

4.Create at a random spot within a radius of your object

This will create a goblin at a random point within a 10 metre radius of the object.

WHEN DO [vectorvar:goblin][=][position][+][random vector][circle][radius][10][inside]
WHEN [Once] DO [create][goblin][at position][vectorvar:goblin]

5. Create at a socket position on your object

WHEN [once] DO [create][acorn][at position][right hand][position]

However if you want the object in the hand of a character you would be better equipping it rather than creating it.


Footnotes:

  1. This ensures the object is created at the same spot, but upside down, and not in the ground or under your world 

Comments are closed.

Website Powered by WordPress.com.

Up ↑

%d bloggers like this: