There are many ways to move objects in HypeHype and this one of them. The Force Component physically moves objects in the game world. Think of it as pushing or pulling the object. The amount of force applied and for how long will determine how quickly the object moves. The Physical Material of objects will determine how much force is needed to move them.
The component has a direction. The direction is based on the node object’s orientation in the game world. If the component is attached directly to the object itself, the direction can be based on the object’s orientation. At it's default position the force is pointing straight up, on the Y axis. With the object or node selected there will be a visible arrow indicating the direction of the force.
Parameters are accessed by selecting the Force component.
|Target||The target object the Force is applied to.|
|Execute||Executes the component.|
|On Start||Executes the component at the start of the Hype.|
|Always||Executes the component on each frame.|
|Enabled||Determines if the component is executable.|
|Turning||Determines if the force should be applied as turning.|
|Affect Physical||Determines if the force can affect the object's Physical component.|
|Local Force||Determines if the force action should be in the object’s local space instead of global space.|
|Reset Speed||Resets object’s speed when executed.|
|Maintain Speed||Keeps object movement direction when executed.|
|Amount||Value how much force is applied to the object.|
Make an Object Jump on a Button Press
Includes using Button component
For this example we'll be using the force to make an object jump into the air when a button is tapped.
Set-Up: We have a simple object placed in our game world, the object can be anything, for this example we'll use the default blue cube. The cube has been given Dynamic physical state so it can be moved by physical force. A Button has also already been set up to appear in the bottom middle of the screen.
Step 1: Spawn a Force Component. The component can be spawned as a stand alone component or embedded in an object. By default the Force Component aims straight up so we can embed it directly into our cube. If we wanted the force to propel our cube in different directions we might want to use a standalone node so that it can be aimed independently of the orientation of it's target object.
Step 2: Connect the button to the character. Before we start adjusting parameters in the Force Component we want to connect our button so we can easily test it. Drag the button link onto the cube and select On Button Press>Force>Execute.
Now we can test our force by tapping the Play Icon to enter a test run of the Hype and pressing the button. Most likely on the first test you'll find that the effect of Force on the cube is too weak or too strong. There are a number of factors that will affect how much force is needed such as the Hype's Gravity as well as the Density and other Physical Material properties.
Step 3: Test the button. At this point we just want to check that the button is activating the force and that physics properties are correct. Unless the object is very heavy you should see the cube move up some amount when the button is pressed.
Step 4: Set the Force component properties
Once the Force Amount is dialed in you are done!