£199.99 £139.99 for one year of Unlimited learning. Offer ends on 14 November 2022 at 23:59 (UTC). T&Cs apply

Find out more
Playing with motion
Skip main navigation

Playing with motion

Practical exercise involving motion
Playing With Motion

Let’s work on some examples relevant to programmed motion

Playing with simple motion
In the previous article, we introduced the animation attribute and the mixin tag and showed you how these can be used to program simple motion in a virtual world. This exercise should help you check if you understood the concepts well enough by completing the tasks below.

Background
To start, use the provided resource [here]. The table below shows the initial and end positions of the three blocks which create a view similar to Figure 1:

Block Initial End
Red [0, 0, 0] [-4, 0, -4]
Green [2, 0, 0] [ 5, 0, -4]
Blue [0, 0, 2] [ 0, 0, 2]

Intitial Positions including faded blocks Figure. 1: Initial positions of the block objects and end positions (faded blocks)

Task 1: Explore how the ‘loop’ property works. Add animations to the three blocks such that:

  • The red block moves to the end position in 3 seconds and stays there [Use the animation attribute]

  • The green block moves to the end position twice as fast as red block and stays there [Use animation defined via mixin]

  • The blue block rotates at the initial position, completing 3 rotations (1 second per rotation) before stopping. [This block doesn’t move to end position]

Task 2: Explore how the direction property works. Add animations to the three blocks such that:

  • The red block moves from end position to initial position. On reaching initial position, it stays there. [The “from” value should match the initial position and the “to” should match final position]

  • The green block moves to end position. On reaching end position, its location resets to initial position and it then resumes motion towards end position. This is repeated 3 times.

  • The blue block rotates in place constantly. On completing one rotation, the direction of rotation reverses. After 3 rotations, it stops.

Task 3: Explore how the easing property works. Modify the final results of task 3 as follows:

  • Red block moves slowly at start but moves really fast after

  • Green block moves fast at start, but slows down as it gets closer to end position

  • Blue block rotates, but slows down momentarily before changing direction

Complete these tasks on your own and compare your code and results with the provided solution resources.

This article is from the free online

Construct a Virtual Reality Experience

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education