Object Referencing GuidelinesThis is a featured page

Objects in the World (and their properties) can be referenced in a variety of ways within a behavior. This creates a great deal of flexibility, but may lead to some unexpected results.

The following are intended as guidelines to help you produce robust and predictable behaviors.


This Object Reference

The use of "this" should be used whenever you are operating on the object where the behavior has been defined. Resist using the object name explicitly. By using this object, you are guaranteed to operate on the right object.

The reference is listed in the object browser and can be accessed under the "this" tab, which also shows the properties for the active object.

For example, when the current object contacts something else, change its orientation.

this reference

Event References

Whenever you are creating a behavior, it's event will be listed under the "other" tab in the Values section of the Behavior Builder. Clicking on the event will show you certain properties of the event, some of which can then be clicked on as well to see what the value references. This image shows the location of the Event object.
event reference
And clicking on the Event object will show you the properties. In this case, we are looking at a collision event, which shows certain properties that describe the collision occurrence:
event reference detail
If we wanted to change the orientation of the object that "this" object collided with, we would click on the "actor2" reference in the Property list, which will show us the properties for that actor which can be dragged into the action, giving us this result:
actor 2 reference

Looping References

When you loop across multiple instances of an object - even if you are doing it from within an object's behavior - you can define your own name to use inside the for-each action. In any location that a new object reference is defined, you can click on that reference to see the properties associated with that object. In this case, we are looping across all rectangles and changing their fill color. The fill color is accessed by clicking on the first occurrence of "rectangle instance," where it is defined.


for each reference


Application and Worl

The Application and World objects are always available in the behavior editor. They are listed along with other objects within the object browser, under the "actors" tab and can be clicked on to access their properties just like the other named references:

app and world reference




No user avatar
dale.beermann
Latest page update: made by dale.beermann , Jul 24 2009, 5:09 PM EDT (about this update About This Update dale.beermann updating for new arch - dale.beermann

205 words added
570 words deleted
6 images added
8 images deleted

view changes

- complete history)
Keyword tags: behavior howto objects
More Info: links to this page
There are no threads for this page.  Be the first to start a new thread.

Related Content

  (what's this?Related ContentThanks to keyword tags, links to related pages and threads are added to the bottom of your pages. Up to 15 links are shown, determined by matching tags and by how recently the content was updated; keeping the most current at the top. Share your feedback on Wetpaint Central.)