|
WHAT IS 3D RAD? CLICK HERE TO FIND OUT!
|
|
|
Understanding Event Objects
Implementing Conditional Behavior Without Scripting
3D Rad objects in general can do the following run-time actions:
Reset. They can go back to their default position, as you defined it in the Virtual Editor.
This action is performed once automatically when the project is run. It can be triggered
at any time, while the project runs, by using event objects.
Hide/Show. You can set the initial shown/hidden state for them in each object's property dialog.
Visibility can be switched on/off at any time while the project runs, by using event objects.
Start/Stop. They can start/stop performing a specific task.
What the task is depends on the object. Some objects do simply nothing, others can do very complex things,
like autonomously driving a car.
You can set the initial working/not-working state in each object's property dialog.
Objects can be started/stopped at any time while the project runs, by using event objects.
Event Objects
Event objects allow you to trigger the actions listed above, for other objects linked with them,
whenever specific run-time events occur or when specific run-time conditions are met.
Run 3D Rad, press [Ctrl]+[N] to clear the project, then press [Ctrl]+[A].
Event objects are those whose name begins with Event.
Double click EventOnInput to add it to the project.
Then press [Ctrl]+[A] again and load the Sprite object.
Link the Sprite and EventOnInput objects together in the Object List.
In the list, double click the EventOnInput item to open the property dialog for it.
In the Relationships box, click the Sprite item until it is set to S/H SWITCH ON INPUT.
What you have done is setting the Sprite object as the target for the EventOnInput event-object.
The Sprite visibility will be switched whenever the [Enter] key input is detected.
You can verify this by launching the project (press [Space]) and then hitting [Enter] a few times.
You can go back to editing mode by pressing [Esc].
One Event Object, Multiple Targets
Each event object can be used to trigger actions for multiple target objects.
Press [Ctrl]+[A] again and add the SoundEffect object. Then link it to the event object.
Open the property dialog for the EventOnInput again and set the SoundEffect target to START ON INPUT.
Open the property dialog for the SoundEffect item and uncheck the Looping and Playing at start boxes.
Run the project and press [Enter]. The above works because the specific action performed by the
SoundEffect object, when it is started, is playing a sound.
Note that the sprite visibility switching is still working too.
More Complex Events
Some event objects allow you to monitor more complex events than simple key presses.
For example, the EventOnProximity object can trigger actions when
a pair of objects get closer than a specific distance.
Advanced Usage
Because event objects perform startable/stoppable actions themselves, you can setup
chains of event objects and achieve complex run-time event management.
The startable/stoppable action of an event object is typically checking if a specific condition is met.
For example, for the EventOnInput, the action could be checking if the [Enter] key is pressed.
For details on the various settings available for a certain event object,
add it to the project, double-click it in the Object List to open its
property dialog and then click the Help button.
|
|