# SetByDerived

### Introduction

SetByDerived is a variable that allows derived Entities to access variables defined in a base Entity. Once a variable is SetByDerived, any Entities that derive from the given Entity (that is, use it as its [BaseEntity](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php)) can set the variable to a different value.

When using inheritance, the derived Entity in code inherits from the base Entity, therefore all variables are available in custom code. The SetByDerived is only useful for exposing the variable in Glue.

### Usage Example

Consider a situation where your game has three Entities: Enemy, Ghost, and Zombie: ![ThreeEntities.PNG](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-29f7e4ef98da0aa799cb29889afef182ea4fe3a1%2Fmigrated_media-ThreeEntities.PNG?alt=media) In this situation the Enemy entity is the base for Ghost and Zombie: ![ZombieBase.PNG](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-9b75d4e29e0601dde803d846ae42b54a4fba7125%2Fmigrated_media-ZombieBase.PNG?alt=media) Notice that by default the Enemy's MovementSpeed variable is not part of Zombie or Ghost: ![NotSetInDerived.PNG](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-e1fd41021f51757f21b690f4cb2d6ffbf43d8100%2Fmigrated_media-NotSetInDerived.PNG?alt=media) If the MovementSpeed in Enemy has its SetByerived value set to True, the variables will automatically appear in the Ghost and Zombie Entities: ![SetByDerived.PNG](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-6c710b43fe04cc7fb2b65f148f6b363f9437b7e1%2Fmigrated_media-SetByDerived.PNG?alt=media)


---

# 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.flatredball.com/flatredball/glue-reference/variables/glue-reference-setbyderived.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.
