# HasPublicProperty

### Introduction

The HasPublicProperty variable on an Object controls whether the object can be accessed by code outside of an instance of the containing Entity. In other words, it controls whether the property created for an object is private or public. This value is false by default, but can be set to public if necessary. ![HasPublicProperty.PNG](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-0f82b9a735a13c455446cea75ee29378eaaeead3%2Fmigrated_media-HasPublicProperty.PNG?alt=media)

### When to set HasPublicProperty to true

The HasPublicProperty is by default false. It is usually set to true when dealing with objects which must expose certain objects to the Screen that contains them. Most commonly, objects need to expose their collision members so that the Screen that contains instances or lists of collidable objects can perform collision logic. If your code attempts to access an object from outside of an Entity but the object's HasPublicProperty is set to false, then you will see a compile error like:

```
<ObjectName> is inaccessible due to its protection level
```

### Base objects define HasPublicProperty

The HasPublicProperty is only available on objects in their base definition. If an object is available in a derived Entity, but defined in the base Entity, the HasPublicProperty value can only be set in the base and not derived.


---

# 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/objects/glue-reference-haspublicproperty.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.
