Tutorial 29: Object Position Event

Thinking outside of the (physics) box...



For this lesson we will back up a bit and cover the event we skipped during the other event tutorials. I saved this one for later because you really need to be able to use data sources and operations.


As we discussed in the physics bubble tutorial, objects outside of a certain range simply cannot have physics properties. You can of course extend the physics range but this can quickly lead to performance issues. However if you want to make objects move that are outside of the physics bubble there is a way and it is called the “object position event.”


When you fire up the properties you’ll see a lot of options we haven’t seen before so let’s run down the list.


-The “Modify Position” checkbox decides if the event will modify the object’s position.


-“Local” determines what coordinates the event will use to move the object. With this checked the object’s current position is zero on all axes. With it unchecked the event will use the world coordinates, this can be used when you want the object follow another object which I will discuss in a moment.


-Next we have values for positions on the X, Y and Z axes. When the event is activated the targeted object will move to whatever position these values dictate and this is where your data sources and operations come into play. If you simply put a new value in here the object will immediately jump to that new location.


Sometimes this will be useful but often you will want the object to smoothly move to the new spot over time so you will need to tie these values to data sources or operations. Manipulating objects in this way is very similar to key frame animation so for the rest of the tutorial I will refer to this as animation.Before we move on to the rest of the properties I’ll give a few basic examples of different ways you can animate objects.


            -If you are animating the object locally the easiest way is with the curved data source. I’ve placed an object here and let’s say I want it to rise up. For this I will tie the Y axis value to a curved data source which I’ve previously set up to change from 0 to 10 over 3 seconds. I will then scroll down to “select event targets” and choose my object.


Now we are almost there but remember this tool is an event so it needs an impulse to activate, also if it only gets one impulse it will only change the position one time to the value in our data source at the time that impulse reaches the event. So what we need is an interval trigger that is sending an impulse to the “object position event” every tick for the duration of the move.


I’ve already set up my interval trigger to send an impulse every tick and then disable after 180 ticks (three seconds) and now I will direct it to activate the object position tool. A simple test in the editor by hitting the back button will show the results, our object will rise up 10 meters.

            -Next let’s consider if we are moving the object globally, a good example of this is getting an object to follow the movement of another object, in my example the rider. For this we will need a few data sources as well as an operation. We’ll start with 3 “object info data sources” I’ve set each one to position X, Y and Z, and set the target object as the rider’s head.


Now at this point I could tie the X, Y and Z coordinates in the object position event to the corresponding data source but this would put my object in the exact position of the riders head and something tells me he wouldn’t like that much.


So now I’m going to use a two input operator to add a couple meters to the Y axis so that the object will be a bit above the riders head. Now I’ll open up my object position event.


First I’ll uncheck the “local” checkbox, the object info data sources are going to produce the global coordinates of their target object so we need the object position event to work globally as well. Next I’ll tie the X and Z coordinates to the X and Z data sources but the Y will use the two input operator as its value target.


Now all that’s left is our trigger, since in this example we want the object to continuously follow the rider, we need the trigger to continuously send impulses. So we will use the same impulse trigger as before with the interval set to 1 tick but this time we will uncheck the “disable after N impulses” option, now the trigger will send impulses continuously and we can point it towards our object position event.


One thing you will notice as I begin my test run is at the start the object will snap to the position above the riders head, this is of course because its starting position doesn’t match up with the starting coordinates of the event.


            - I’ll cover on more method of animating objects then we’ll get back to the event’s remaining properties. This time we are still going to be moving globally but instead of having the object follow another object it is just going to move from point A to point B.


For this method we will need two objects in the world to pull location data from, one at the starting position and one at the end so I will spawn a dummy object then copy it and move the second one to my end position. Now we will need three object info data sources for each dummy object one for each axis.


To save time I’ve already set these up and connected them to the dummy object. Now we also need 3 “curved data sources” again one for each axis. Now I’ll grab my first curved data source and tie the starting value to the X data source of the first dummy object and the end value to the x data source of the second dummy object and I will also set the duration to 3 seconds.


I’ll repeat this step with the other two curved data sources using the Y and Z object info data sources. Once that is done I will connect the X, Y and Z position values in the object position event to the corresponding curved data source, our object is already selected and the trigger already set up from the previous example.


Now all that’s left is a quick test to see how our object will move. There is one last thing to note that would be useful when animating globally. In both of our global examples there was a jump at the start of the animation because the X, Y and Z values of the starting position didn’t match up with the actual position of the object.


If you want these values to be equal before you connect the object position event position values to the curved data sources if you highlight them in the properties menu and hit the X button the value will automatically change to the position of your targeted object, you can then take that number and use it as the starting value in your curved data source.


Once you’ve repeated this for each axis, attach the object position event values to the curved data sources. This eliminates the need for the first dummy object and its object info data sources. Now you may still get a slight jump because the curved data source will not allow you to input the decimal values so if you need to use this method you will want to try and get your object as close to whole number coordinates as you can.


I hope that gave you solid idea on the many options you have for animating objects. There are of course other methods but once you understand the basics of using this event the possibilities of what you can do start to expand exponentially.


Now that was a lot of info but we’ve still got more to cover. Fortunately the next set of options work basically the same but now for rotation instead of position.


-The “Modify Rotation” checkbox of course decides if the tool will try to change the rotation or not and just as before “local” determines if it will use the values of the object as a base or global values.


-Yaw, Pitch & Bank refer to the different types of rotation, these are basically technical terms that have to do with rotation but the concepts are the same as the 3 axes we are used to working with. The easiest way I’ve found to understand these are some visuals from aviation manuals (recreate aviation graphics depicting Yaw, Pitch & Bank).


Basically, Yaw is rotation on the Y axis, Pitch is rotation on the X axis and Bank is rotation on the Z axis.Since we are dealing now with rotation instead of position our values here represent degrees of rotation instead of meters, so a change from 0 to 360 would be one full rotation. Besides that the potential processes of animating rotation are the same as they were for position so I will not do any further examples here.


There is one other difference when modifying rotation. When the “local” checkbox is unchecked a new option appears called “set rotation.” When using global coordinates the game will still use that object’s current rotation as the baseline so a zero in yaw, pitch and bank will have no effect. By selecting the “set rotation” checkbox, zeros in the three fields will now return that object to its default rotation. This can be useful if you want to have multiple objects rotate together exactly the same way.


And all of our remaining options are ones that hopefully are fairly familiar to you know by now so that concludes our lesson on the “Object Position Event”