Sometimes you want to alter the value of a property at particular points in time. This is where Pulses come in. Pulses represent events that fire at a particular intervals. We can alter property values or attach script that gets called every time the Pulse fires.
Let's see how we can use a Pulse to cause a sphere to expand then quickly collapse itself at a particular interval.
- To begin, let's start fresh by clicking on File menu/New.
- Next, let's draw a sphere. Undock the toolbox panel
- Select 'entities' from the top list of the toolbox
- Select 'sphere' from the bottom list of the toolbox
- Now, left click and drag in the space to draw a sphere
- Right-click to exit draw mode
Next we'll create a ConstantPulse, which will fire events in a repeating pattern.
- Undock the browser panel
- Next, click the + button at the bottom right of the browser panel
- From the menu that appears, select Pulses, then click New ConstantPulse
We now have a ConstantPulse that is pre-configured to fire every second. We'll adjust the rate later. Before that, let's assign the Pulse to make it expand our sphere's radius every time the Pulse fires.
- Double-click the sphere in the space
- Next, drag-and-drop the ConstantPulse from the browser onto the Radius property of the Sphere on the property editor panel
- Click Play to see what happens
Our sphere should pulse every second. Because the sphere has a movable RigidBody, physics will act upon it which might be undesirable. Let's make the sphere un-movable so it pulses in place.
- Click Stop
- Ensure the sphere is selected, then from the property editor panel, select RigidBody from the left list
- From the right list of the property panel, set the Movable property to false
Now we can place the sphere wherever we want and it will pulse in place. Let's change the rate it pulses.
- From the browser panel, double click the ConstantPulse
- On the property editor panel, set the Frequency value to 2
- Click Play
The Frequency here means pulses per second so our sphere should pulse 2 times per second now. Lastly, let's look at how to adjust the radius is affected by the pulse.
- Click Stop
- Double-click the sphere
- From the right-list of the property editor panel, expand the Radius item by clicking on the arrow to the left of Radius
- Expand the NumberPulseController as well
- Finally, set the Offset value to 0.5
- Click Play
The Offset represents how much is added to the radius every time it pulses. It will be added to whatever value the sphere begins with when Play is pressed. You can try playing with the other properties of the NumberPulseController to control the pulse animation style and timing.