# Simulate Actors with Kinetics Properties Using MATLAB

This example shows how to set kinetics properties such as `Force` and `Torque` to simulate actors in the Unreal Engine® simulation environment using MATLAB®.

First, you use the `sim3d.World` object to create a 3D environment. You then use the `sim3d.Actor` object and functions to build sphere and box actors and set the physical properties of the actors. Then, you add the actors to the world and set a view in the scene. Finally, view the animation in the Simulation 3D Viewer window.

Unreal Engine® uses the physics engine to control actor motion and perform real-time physics calculations when the physics property of an actor is enabled.

### Create 3D Environment

Create a world object.

`world = sim3d.World();`

### Build Sphere and Box Actors

Instantiate actors named `sphere` and `box`. Use the `createShape` function to build sphere and box shapes of specific sizes or use the default unit sizes. Set the `Mobility` and `Physics` properties of the actors to react to physical forces.

Specify the color and initial position of `sphere`. Use the `Force` property to apply a force of `[0 10 0]` to the `sphere` actor. Add actor to the world.

```sphere = sim3d.Actor(ActorName='sphere', ... Mobility=sim3d.utils.MobilityTypes.Movable); createShape(sphere,'sphere'); sphere.Translation = [2 -2 2]; sphere.Color = [1 0 0]; sphere.Force = [1 10 0]; sphere.Physics = true; sphere.Mass = 1; add(world,sphere);```

Specify the color and initial position of `box`. Use the `Torque` property to apply a torque of `[0 0 pi/2]` to the `box` actor. Add actor to the world.

```box = sim3d.Actor(ActorName='box', ... Mobility=sim3d.utils.MobilityTypes.Movable); createShape(box,'box'); box.Translation = [2 0 -1]; box.Color = [0 0 1]; box.Torque = [0 0 pi/2]; box.Physics = true; box.Mass = 1; add(world,box);```

### Set Viewer Window Point of View

If you do not create a viewport, then the default view is set and you can use the keyboard shortcuts and mouse controls to navigate in the Simulation 3D Viewer window.

For this example, use the `createViewport` function to create a viewport.

`viewport = createViewport(world,Translation=[-10 0 0]);`

### Run Animation

Run the animation set for `20` seconds with a sample time of `0.02` seconds.

```sampletime = 0.02; stoptime = 20; run(world,sampletime,stoptime)```

### Delete World

Delete the world object.

`delete(world);`