As you develop bigger and more complex projects, you must understand how to apply actions to individual instances of objects. The process of filtering out objects is called object scoping or object selection within MMFusion. This guide explains the various fundamentals of object selection in MMFusion.
Object scoping is the filtering of certain objects within events. Any actions within these events are only applied to objects within the event's object scope.
How is Object Scope Used?
Object scope is primarily used to apply actions to objects meeting certain requirements/conditions. If, for example, you wanted to increase an object's X-position anytime the user clicks on the object, you would scope to the object(s) within the condition list, as shown below.
Did You Know
How Can I Manipulate Object Scope?
As mentioned above, an event's object scope is directly related to its condition list. Every condition in MMFusion can reduce the number of objects within the scope. Another way to think to think of it is that every condition is a filter test. Objects that explicitly fail this test are removed from the object scope. The below image shows a conceptual drawing of how object scoping works.
Example of Object Scoping
The below two images demonstrate a basic example of object scoping with one type of object. Suppose there are 12 circles, as shown in the "Object Scope in Action" image. Each circle has an ID, varying from 1 - 12, and is colored either red, green, or blue.
The logic for this basic example is as follows
At the start of an event's condition list, all objects are within the object scope, as shown in the below image.
The "Circle ID is even?" condition filters out all circles with odd IDs. As a result, only 6 circles (2, 4, 6, 8, 10, and 12) are left.
The next condition ("Circle is red?") filters out all non-red circles. This leaves us only with red circles with even IDs; circles 2 and 4.
Since we are at the end of the event's condition list, the object scope no longer change. Now any action involving the "Circle" object will only affect circle 2 and circle 4.
If we wanted to affect other circles, such as only blue circles with an odd ID, we would need to add/remove conditions as needed to fit our requirements. That being said, there are two fundamental types of conditions in the object scoping/select context; object-oriented conditions (OOC) and object-independent conditions (OIC).
Object-oriented conditions are conditions which let you filter out individual instances of an object. All conditions found under the "Active Object", for example, are object-oriented conditions. You know this because if you have the event
+ Active Object's Alterable Value A = 1
- Destroy Active Object
only Active Object instances whose Alterable Value A = 1 would get destroyed, rather than every instance of Active Object when one instance's Alterable Value = 1. Similarly, the "User Click clicks on object" and "Mouse is above object" conditions under the Mouse and Keyboard object are also object-oriented conditions. When the mouse clicks on a specific instance, any action is applied only to the clicked object.
Object Independent Conditions
Object-independent conditions are conditions which include/exclude all instances of an object. It's basically an all or nothing filter. Either all instances are included in the object scope or all instances are excluded from the object scope. If a condition refers to an object's expression, but the condition is not found under the same object, the condition is most likely an object-independent condition.
The most commonly used object-independent condition is the "Compare Two General Values" condition, found under the System Object. This condition allows you to compare any two expressions from any object. Since this condition is an object-independent condition, the event's actions will usually apply to all instances of the object which can result in sudden bugs in your program. It's barely noticeable if only one instance of the object exists during runtime, but adding more will highlight the issue.
In summary, here are the basic need-to-knows for basic object scoping/selection
Object scoping is the process of preventing actions from acting on specific objects
Object scoping entirely depends on the conditions within an event
Every event has its own object scope. This scope is renewed for frame loop for every event
There are two types of object-scoping conditions; object-oriented conditions and object-independent conditions
Object-oriented conditions allow you include/exclude individual object instances from an event's object scope
Object-independent conditions, such as the "Compare Two General Values" condition, exclude/include all object instance from an event's object scope
Check out the PDF and example MFA for some additional knowledge about object scoping such as the consequences to object scope when using fastloops. Future tutorials will delve into the more advanced/technical aspects of object scope. If this tutorial helped you, rate it accordingly below! Also below is set of screenshots (from the example MFA) describing object scope. Clicking any image enlarges the image and shows some context for the image
Click an image to read related information. All images come from the "Object Testing/Experiment" within the MFA example file under the "Downloads" section.
Rate This Tutorial
If you have read this tutorial, rate it from poor (1) to average (3) to great (5)!