# Simulate Actor with Kinematics Properties Using MATLAB

This example shows how to simulate an actor in Unreal Engine® simulation environment by setting kinematics properties using MATLAB®. You build sphere and box actors to animate. To simulate an actor in Unreal Engine® simulation environment by setting kinematics properties using Simulink®, see Simulate Actor with Kinematics Properties Using Simulink.

First, you create a 3D environment using `sim3d.World` and build the actors using `sim3d.Actor` classes. Then, you set actor properties to enable mobility and set a view in the scene. Finally, you view the animation in the Simulation 3D Viewer window.

### Create 3D Environment

Create a world object.

`world = sim3d.World();`

### Build Actors

Instantiate the actor objects named `sphere` and `box`. You can use any name for the actors. Use the `createShape` function to build `sphere` and `box` shapes for the actor objects and specify the size. Add the actor objects to the world.

```ActObj1 = sim3d.Actor('ActorName','sphere'); createShape(ActObj1,'sphere', [0.5 0.5 0.5]); add(world,ActObj1); ActObj2 = sim3d.Actor('ActorName','box'); createShape(ActObj2,'box', [0.5 0.5 0.5]); add(world,ActObj2);```

### Set Movable Actor

Use the `sim3d.Actor` properties to create a movable actor. Use the kinematics properties `LinearVelocity` and `AngularVelocity` to move and rotate the actors `ActObj1` and `ActObj2`, respectively.

```ActObj1.Translation = [1, -2, 1]; ActObj1.Color = [0, 1, 1]; ActObj1.Mobility = sim3d.utils.MobilityTypes.Movable; ActObj1.LinearVelocity = [0, 0.5, 0]; ActObj2.Translation = [1, 0, -1]; ActObj2.Color = [1, 0, 1]; ActObj2.Mobility = sim3d.utils.MobilityTypes.Movable; ActObj2.AngularVelocity = [0, 0, pi/4];```

### Set Viewer Window Point of View

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

Use the `createViewport` function to create a viewport with a single field, `Main`, that contains a `sim3d.sensors.MainCamera` object.

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

### Run Animation

Run a simulation set for `10` seconds with a sample time of `0.02` seconds.

`run(world,0.02,10)`

### Delete World

Delete the world object.

`delete(world)`