Alice 3D Programming Training for Students

The Alice 3D Programming Training for Students of KV Kanjikode will commence from next week (July third week). 

The interested students (both the first batch of students and those who wish to join) may contact the Librarian.


Variables are used to store data. It is a named storage location in the computer memory.
To use a variable in Alice we need to create it first. The creation of a variable is simple. Just drag the variable tile from the control area to the code area and provide a meaningful name, value type and initial value.

Example Using Variable
In this example we will use two variables to store the heights of theboy and thegirl and then display the values stored in the variables making use of the say procedure and mathematical function we have learned earlier.
 The steps involved:
1. Create a variable height_boy, value type Decimal Number and Initial value 0.25
2. Create a variable height_girl, value type Decimal Number and Initial value 0.25
3. Drag and drop the getHeight functions to the respective value places
4. Use the say procedure to display the values



The functions are available under the methods panel in Alice.
Functions are used to get various properties of an object. They are like procedures and returns a value. For example, you can get the height of an object which can be later used to compute or compare the value with another value.

You can see some of the functions listed for the object selected. For the example, we will use the function getDistanceTo to move the theboy move towards thegirl.

In the above video tutorial, first we used the turnToFace procedure to turn theboy to face thegirl.
Next statement is used to delay the action so that the movement will be visible (try this without the delay statement)
Then we added the procedure moveToward and selected the initial value for distance. Now we can make use of the function getDistanceTo to calculate the distance to be moved. See the regions being highlighted while we drag the function to the statement area. The function is placed in the distance value and theboy now moves towards thegirl.
Did you notice the problem here?
Yes! theboy has moved to thegirl now and is colliding with thegirl. Is this what we needed?
No. We need theboy to move nearby thegirl. So to avoid the collision we can make use of the mathematics operators to reduce the distance to be moved.
The video given below demonstrates how this can be achieved.

To use the mathematical function, click the outer arrow on right to the getDistanceTo function. Select Math from the dropdown list and then select the desired mathematical function (here getDistanceTo - ??? as we need to reduce some amount from the value returned by the function getDistanceTo) followed by the value as shown.

You can see that many mathematical operators (addition, subtraction, multiplication and division) with various options are available here.

Next: Variables

Get the new version of Alice - Alice 3.1.60

Dear Students
A new update for Alice is available for download at
The new version has got more 3D objects to try. New animals, plants, properties and a few vehicles are added in this version.

Alice 3.1 Tutorial Part 6: Functions

Alice has got a set of functions that provides information regarding the any object as required like the direction, its size, its distance to or from another object etc. Functions also helps us to get inputs from the user so that interactivity can be provided in the animations. For example you can get the name of the user or you can ask the user how much an object is to be moved and in what direction. Based on the user inputs you can code to manipulate the objects in different ways.

Besides, access to various body parts of an object is also obtained using the functional methods. You can find many functions listed which provide access to the internal joints of an object. The available joints depends on the individual object. Though some of the joints may be similar to all the objects belonging to a particular class, each individual object may have some joints that are specific to that object only.

Getters or Functions to get the dimension values of an object

In the image shown here, the three dimensions of the object girl can be accessed using these functions.

For example, you have two objects on the stage - one boy and one girl. You can resize the girl to make that object's size equal to that of the object boy using setHeight procedure

First we will drag and drop the code this.girl.setHeight to the code editor. Initially we may select any value.
Next, select the object boy in the object tree and click on Functions tab on methods panel. When you click on the code this.boy.getHeight, you can see Alice highlighting the value in the code editor where you can place the function.

When you click run the code will be executed resizing the girl to the same height as the boy. Observe that the three dimensions are automatically resized proportionately. 

If you use any of the procedures below instead of the setHeight procedure mentioned in the first step above, the object will be resized in one dimension only.

will be continued...

Alice 3.1 Tutorial Part 5: More Programming in Alice

You have learned the basic movements in the Begin to Program tutorial
Now we will see some more procedures available under the methods panel. You can also make custom procedures using these built-in methods.

Here we have the object cheshireCat selected in the object tree.
 The turn procedure turns the objects on their center point to left, right, forward and backward. When turn procedure is used, the object sense of forward will change accordingly.
The roll procedure rotates or rolls the objects on their center point to left or right ie. clockwise and anticlockwise. In roll procedure, the object's sense of forward remain unchanged. See the turn procedure used below to turn the boy to face the girl.

0.25 turns the objects at 90 degrees. A full turn of 360 degrees can be achieved by providing the value 1.

Both the turn and roll procedures can be applied to an entire object or a part of the object.

turnToFace the object will turn to face the other object selected as the argument (object will turn around its pivot point, so that its sense of forward will be in the direction of the target) and the pointAt procedure will rotate the object around its pivot point, so that its sense of forward will be in the direction of the target's pivot point. Both these procedures will look similar to the turnToFace procedure if you try it with two objects at the same level.
The difference will more clear in a scenario given below where we have applied both turnToFace and pointAt to the body part - right shoulder.

orientToUpright Animates a rotation of the object around its pivot point making the object to stand upright

orientTo the object will be rotated around its pivot point to have the same orientation as the target object.
straightenOutJoints gets the joints of an object to its original position.
Say is used to show the objects speak. A speech bubble will appear with the text you have provided.
Think works similarly, but a thought bubble will appear with the given text.

Resizing an object
The objects can be resizes at runtime using the following procedures.

When you set any of the three dimensions, the object will be resized proportionately. The size boy in our example above can be increased by the following procedure. We need to set only one dimension and the height and depth will be adjusted accordingly

Most of the procedures have an add detail parameter having the options asSeenBy, duration, and animationStyle which will affect the animation style of the objects.

Vehicle Property or setVehicle Procedure
Any object in Alice can be set to act as the vehicle of another object. When you set an object as the vehicle of another object both objects are synchronised and when the vehicle moves the other object will follow the same movement. An object cannot act as a vehicle for itself and two object cannot have a reciprocal vehicle relationship.
The vehicle property will be useful in the scenarios like a person riding a vehicle or horse or a pet follows its master. An object can be set as the vehicle of the camera so that the camera will follow the object when it moves.

Practice these procedures to get an idea of how they work.