Quick Physics - The events
4. Applying some basic physics via Event Editor
For the sake of this guide, we're not going to create a 'game' per-se; we're going to create a kind of testbed to get you settled with Physics in Clickteam Fusion 2.5. Click on the Box object, select the Runtime Tab of the property pannel and uncheck 'Create at Start'. We're doing this because we don't want Fusion to create the box object at the start, we want to create it ourself, from the event editor. We're going to create a simulation of boxes falling from the sky. Let's head over to the Event Editor.
Let's create a new condition : click on the New condition line. Then right click on the Keyboard & Mouse object and select The Mouse > User Clicks. In the prompt dialog, choose Left Mouse.
Once you've inserted this condition, hover over to the 'Create Object' icon, right-click and select Create Object.
Click on the 'Box' object and click OK.
Fusion will then ask you where you want to create the object. Select anywhere for now, it doesn't matter because in the next action we will tell the object to instantly move to where the mouse is. So in effect, our object is going to be created wherever we click. Once you've clicked OK, then on the same condition line, hover over to the box, right-click and select Position > Set X Co-ordinate.
When prompted with the expression editor, type in 'Xmouse' and click Okay. Repeat for the Y Co-ordinate and use 'Ymouse' in the expression editor. Once you've done that, save your file and run the application. You should now be able to click anywhere on the screen and create a box.
So we can now create boxes and as many as we want just by left-clicking anywhere in the frame, very nice. Now, our box is still dropping straight through our 'Ground' object we laid earlier. This is because you need to tell Clickteam Fusion 2.5 what to do when certain objects collide with other objects. So, let's create a new condition. Select the Box object, right-click and select Collision > Backdrop.
Now, just a note. This does NOT imply 'stopping' the object (speed wise). You are telling Fusion here, if the box collides with the ground stop the box at the collision point, not decelerate. Gravity is always being applied and depending on what angle the box collides with the ground, it could still be moving. However, with the way we have our flat surfaces laid out, this shouldn't be an issue for the moment.
Hit F8 and run your application, start creating some boxes and notice how they now stop when they make contact with the ground. But the boxes are falling through each other?
Again, we need to tell Fusion about this. We need to say when a Box collides with another Box, stop the movement. This will stop the objects from overlapping each other.
So, let's create another condition, right-click on the Box object and choose Collisions > Another object. Then enter the action Movement > Stop.
Once you've done this, hit F8 and run the application again. Now create lots of boxes in lots of different areas of the frame and watch the magic come together. We have created this in literally, 3 events and just 5 actions.
You can now have a play about inserting more objects, such as balls and applying Circles to the Collision Shape in the object properties and much, much more.
Do drop in some of the other Physics objects (extensions) available in the extension manager. All of them come with available help files and examples in the Clickteam Fusion 2.5 folder.
Spread the word!
You can share this document using the following buttons.