# Creating actor classes

Actors are implemented as classes in you project's code.

### Creating a new actor class

The actor class is defined in a `.ts` file in your code. A convention is to place these in the folder `src/actors`. In the code below, we have a basic starting point for an actor.

```typescript

// src/actors/example-actor.ts
import { Actor, BaseActor } from "@hology/core/gameplay";

@Actor()
class ExampleActor extends BaseActor {

  onInit() {
    
  }
  
  onBeginPlay() {
  
  }
  
  onEndPlay() {
  
  }
  
  onUpdate(deltaTime: number) {
    
  }
  
}

export default ExampleActor 

```

This is all you need if you only intend to spawn the actor through you game.

#### Making actors available in the Hology Editor

In addition to defining your class, you need to export it. This is done in the `index.ts` file. If this is not done, the editor will not be able to find your actor class.

```typescript

// src/actors/index.ts
import ExampleActor from "./example-actor";

export default {
  ExampleActor,
  // add other actors here
}

```

### Creating an actor class from the editor

An easier way to create the starting code for an actor is to do it through the editor. It will generate code for you with a given actor class name. Click the Add new button in the asset browser and select Actor class.

<img src="/files/AdvfpUfJ2Q50bUOPWy9T" alt="Create actor classes from editor" data-size="original">

### Hot reloading

The editor will monitor your code to find any new actor classes that can be instantiated as actor instance in your scenes. Also, if the actor code changes, actors in in your scene will be refreshed to reflect any visual changes.


---

# Agent Instructions: 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:

```
GET https://docs.hology.app/gameplay/actors/creating-actor-classes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
