RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


A Speed Guide to Virtual Driving in Second Life

Find out how to use Linden Scripting Language to control virtual vehicles in Second Life.

n Second Life (SL) users can fly nearly anywhere in superhero style. They can also teleport from one place to another in seconds—without any assistance from any sort of device. These capabilities make travel in Second Life easy; avatars have no need for vehicles. Flying and teleporting are inherent abilities that all Second Life users possess.

Curiously, despite being completely unnecessary, vehicles are still very popular in Second Life. Many SL stores offer a wide array of cars, helicopters, boats, planes, and many other types of vehicles. Several real-world carmakers also create SL versions of their vehicles, adding promotion through SL to their marketing arsenals. Figure 1 shows several cars in Second Life.

Figure 1: Cars in Second Life: Despite being unnecessary for travel, vehicles of all types are still popular in Second Life.
But unlike real-world vehicles, you aren't limited to the offerings of vehicle manufacturers; with a little effort, you can create your own. This article demonstrates how to create a basic car in Second Life.

Constructing the Car Body
Figure 2: The Car Example: Although it may not be pretty, this wagon-like car uses the same basic script as a more attractive vehicle.
Car bodies can become very complex in Second Life. To make SL cars appear as realistic as possible, designers typically use an array of prims (primitive shapes) to create complex shapes. While you're free to do the same, the purpose of this article is not to explain how to build a realistic—or even an aesthetic—car. Instead, the purpose of this article is to explain how to script a car—writing the code that makes it work. You'll see how to create a reusable car script that you can use as the basis for other SL land-vehicle projects.

Therefore, the car that you'll create in this article has a very simple wagon as its body (see Figure 2).

Building the car example is very simple—all you need is a hollow box, four wheels, and a seat. Despite its simple construction, a few elements are necessary for the car to function properly.

The Root Prim
The root prim is very important. Most objects in SL are made up of many prim objects. Even complex objects such as cars are simply a collection of prims. However, not all prims are created equal. The last prim to be added to the car becomes the root prim. For vehicles, the root prim is particularly important because:

  • The vehicle script resides in the root prim.
  • All vehicle motion is relative to the root prim.
  • All vehicle rotation is relative to the root prim.
For Second Life vehicles, the root prim is almost always the driver's seat. You can make the vehicle construction much easier if the root prim is at rotation <0,0,0>. Because vehicle motion occurs relative to the root prim, rotating the root prim will affect how force is applied to move the vehicle.

As a car moves it rotates in all three dimensions, turning left and right (one dimension) and rolling from side to side (another dimension) when it is on uneven pavement. The car also pitches up and down as it travels hills. Second Life accomplishes all car rotation by rotating the root prim, because it "sees" the entire vehicle as only the root prim. Every other object on the car moves solely by virtue of the fact that it is attached to the root prim. For the car shown in Figure 2, the root prim is a black box that the avatar sits on.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date