> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/flatredball/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/flatredball/api/flatredball/positionedobject/initialize.md).

# Initialize

### Introduction

The Initialize method can be used to reset the PositionedObject variables back to their default state. Specifically, the Initialize method resets:

* Position (absolute and relative)
* Velocity (absolute and relative)
* Acceleration (absolute and relative)
* All ["real" values](https://github.com/flatredball/FlatRedBallDocs/tree/main/frb/docs/index.php#Real_Velocity_and_Acceleration)
* Rotation (absolute and relative)
* Rotation Velocity (absolute and relative)
* Attachments (detach from parents)
* Attachment properties ([ParentRotationChangesPosition](https://github.com/flatredball/FlatRedBallDocs/tree/main/frb/docs/index.php) and [ParentRotationChangesRotation](https://github.com/flatredball/FlatRedBallDocs/tree/main/frb/docs/index.php))
* Instructions
* Name
* List membership **(see below for more information)**

### Method Signature

The signature for Initialize is as follows:

```
public virtual void Initialize()
public virtual void Initialize(bool clearListsBelongingTo)
```

Arguments:

* bool clearListsBelongingTo - Whether the object should clear its [ListsBelongingTo](https://github.com/flatredball/FlatRedBallDocs/tree/main/frb/docs/index.php) property. If this property is not specified, then the default value is true.

### The dangers of clearListsBelongingTo

The FlatRedBall Engine depends on the two-way relationship that exists between [IAttachables](https://github.com/flatredball/FlatRedBallDocs/tree/main/frb/docs/index.php) (an interface of the PositionedObject) and two-way lists that the [IAttachable](https://github.com/flatredball/FlatRedBallDocs/tree/main/frb/docs/index.php) belongs to. Calling the no-argument version of Initialize, or passing **true** as the argument will result in the the PositionedObject breaking its two-way relationships with other objects, **but it will not be removed from those lists**. Let's look at a simple example where this can cause errors. The following code creates a PositionedObject, adds it to the SpriteManager for management, initializes, then attempts to remove it:

```
PositionedObject positionedObjectInstance = new PositionedObject();
SpriteManager.AddPositionedObject(positionedObjectInstance);

// This will clear the PositionedObject's ListsBelongingTo.  This means that the PositionedObject will
// no longer know that it belongs to the engine, so it will not be able to remove itself from the engine.
positionedObjectInstance.Initialize(); 

// This call will not do anything!
SpriteManager.RemovePositionedObject(positionedObjectInstance);

// If you want to test it, try this:
if(SpriteManager.ManagedPositionedObjects.Contains(positionedObjectInstance))
{
    throw new Exception("The PositionedObject wasn't removed!");
}
```

To avoid the bug shown above, you should either:

1. Initialize before adding to the SpriteManager
2. Pass **false** as the argument to Initialize


---

# 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.flatredball.com/flatredball/api/flatredball/positionedobject/initialize.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.
