> For the complete documentation index, see [llms.txt](https://docs.hology.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hology.app/gameplay/actors/moving-actors.md).

# Moving actors

After an actor is added to your scene, either by placing it in the editor or by spawning it at runtime, you may want to move it to a different location or to rotate it. There are two approaches to this:

* Directly set the new position and rotation on the actor
* Simulate physics by adding the actor to the physics system with a dynamic or kinematic physics body.

## Setting the transform on an actor

If your object should not neceserilly adhere to laws of physics, you can simply set the position and rotation using the actor's position and rotation properties. This will update the rendered transform of the object but it will not update it in the physics world. For that to happen, you also have to apply the actor's transform through the physics system.

In the example below, we have an actor with a rendered and physical representation given by the collision shape. On each frame, we update the actors position according to a speed and direction.

```typescript
@Actor()
class BallActor extends BaseActor {
    private physics = inject(PhysicsSystem)

    public speed = 0.4
    public direction = new THREE.Vector3(0,0,1)

    private mesh = attach(MeshComponent, {
      mass: 1,
      bodyType: PhysicsBodyType.static,
      object: new PhysicalShapeMesh(
          new SphereGeometry(.2, 20, 10),
          new MeshStandardMaterial({ color: 0xeff542 }),
          new SphereCollisionShape(.2))
    })
    
    onUpdate(deltaTime: number) {
        this.position.addScaledVector(this.direction, this.speed * deltaTime)  
        
        // Also update the physics system so that the physics body is updated
        this.physics.updateActorTransform(this)       
    }
    
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.hology.app/gameplay/actors/moving-actors.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
