User Tag List

Results 1 to 8 of 8

Thread: Physics question - how to detect end of movement?

  1. #1
    Clicker Install Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Ken1171's Avatar
    Join Date
    Sep 2016
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Physics question - how to detect end of movement?

    Hi! I am making a physics-based game with Clickteam Fusion 2.5, and it uses only simple boxes that fall from the top over a platform. Some will fall off, and some will pile up on the platform. I need to perform an action (calculate score) when all the boxes stop moving. The ones that fall off the platform are destroyed, but if they are still falling, that needs to count as moving as well. In other words, I can only calculate the score after all movements have completed.

    Is there an event when the simulation ends? If not, how can I detect when all boxes have stopped moving or falling? I have tried making a loop that checks all boxes for speed greater than zero, but that is rather cumbersome. What would be the proper way to do this?

  2. #2
    Clickteam Clickteam
    Jeff's Avatar
    Join Date
    Jun 2006
    Location
    Battle Ground Washington
    Posts
    11,822
    Mentioned
    7 Post(s)
    Tagged
    2 Thread(s)
    What about testing the speed of the object?
    If its 0 its done moving.

  3. #3
    Clicker Fusion 2.5Fusion 2.5+ DLC
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    643
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Expanding on Jeff's suggestion, a counter using an alterable value could help you here, since if an object's speed = 0, but only momentarily before moving again for some reason, it could mess your score tallying up.

    Object value < Object value limit
    --> add 1 to object value

    if Object is moving
    --> set object value to 0

    if Object value >= Value limit
    -->object is done moving

    Then when all of your object's are greater or equal than their timer limit, you can tally score.

  4. #4
    Clicker Install Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Ken1171's Avatar
    Join Date
    Sep 2016
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jeff View Post
    What about testing the speed of the object?
    If its 0 its done moving.
    That's what I tried, but I am new to Fusion and the way loops work in there are still rather confusing to me. I am coming from programming languages where a FOR loop is just a statement. Took me a while to understand how this works in Fusion, since we first have to declare it, then define it, and then create and handle its event listener. Perhaps the documentation could elaborate more of such things to make it easier for programmers to learn the Fusion mechanics. I have searched the documentation for "loops" or "for loops", but found nothing.

    Quote Originally Posted by casleziro
    Expanding on Jeff's suggestion, a counter using an alterable value could help you here, since if an object's speed = 0, but only momentarily before moving again for some reason, it could mess your score tallying up.
    Exactly what was happening here - some boxes were resting in place, but at some point were moved by other boxes, so just counting the boxes that were not moving wasn't helping at all.

    I am new to Fusion, so I am not sure of some things. I have a couple of questions:

    1. If I make a timer loop and condition it to check for boxes with zero speed, does that automatically makes Fusion to check *all* boxes? Or just the last one that was referenced? How do I know what is being referenced?

    2. There doesn't seem to be a way to perform a IF/ELSE statement with different conditions for each one in a timer loop (or anywhere else). If I condition a timer event to one condition, and then just below it do it again for another condition, does this mean I am running the timer twice? I suppose that would be the equivalent of 2 IF statements that will be executed one after the other. Is there a way to make the equivalent of an IF/ELSE statement?

    Thanks!

  5. #5
    Clicker Fusion 2.5Fusion 2.5+ DLC
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    643
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    1. Yes, it will check *all* boxes unless otherwise specified (i.e, you supply another IF condition that would further narrow the object scope)

    2. I'm not sure what you mean by "timer". But all of your events are read once from top to bottom, every frame with the exception of Fast Loops (which complete all of their iterations instantly in a single frame when the event that calls them is reached) or "Loop-like" actions, such as For Each and etc. I think green is the color given to Immediate actions, such as Start of Frame, Fast Loops, For Each Loops, and so on.


    If for example you had something like this:

    Always
    --> move object 1 pixel forward

    Always
    --> move object 1 pixel forward

    Then yes, you will move that object twice. In Fusion, the top "condition" in any line is your IF. Any conditions you insert to be beneath that initial condition (you can insert conditions by right-clicking on the current one and clicking "insert condition") are the equivalent of AND:

    Object is overlapping ground
    +Object's value = 0
    --> Destroy Object

    Would read like this in any other language:

    IF Object is overlapping ground AND Object value = 0 THEN
    --> Destroy Object


    There is no default ELSE function, but through a clever use of event Groups you can do much the same thing. You would want this group to be de-activated at start, and activate it manually each frame.

    Always
    --> open group "test"

    [GROUP TEST]

    Object value = 1
    --> change object animation to Stopped
    --> close group "test"

    Always
    --> change object animation to Walking

    This would translate to:

    IF Object value = 1 THEN change object animation to Stopped, ELSE change object animation to Walking.

    Here, because the group is closed when the first event is true, you've effectively created your own tree of ELSEs. If the first condition in the group isn't met, then the second one will run, and so on. But any time a condition is met, then the group gets closed and none of the others run.


    As for object scope, here's an older article explaining it more in-depth: http://www.create-games.com/article.asp?id=1942

  6. #6
    Clicker Install Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Ken1171's Avatar
    Join Date
    Sep 2016
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for the explanation. A FOR loop wouldn't help in my case, since I have to keep checking for box movement until there is none. Therefore a "timer" loop is the only viable choice. This is a condition created from "The Timer" object in Fusion. It's the equivalent of a Timer class in ActionScript, and works pretty much the same. As a matter of fact, the FOR loops in Fusion also work the same as the Timer class in ActionScript, in the sense that it's a class (not a simple FOR statement), so it has to be created, defined, and the events have to be listened to and implemented. This means that basically all loops in Fusion are classes, instead of the usual statements found in programming languages. It would had saved me tons of time (and tears) if the documentation would had explained that when I got started. ^^;;

    Timers are endless loops that have to stopped manually with an asynchronous "stop" call somewhere else in the program. It's the same in Fusion. They are declared in the Fusion event list as:

    Every 01-00
    --> do something

    This means "do something every second".

    Hmm, so there is no ELSE statement. Thanks for clearing that out for me - I was going crazy trying to find it. The way you have implemented the workaround looks pretty much like a "switch" statement from C/C++ and ActionScript. We have to add all conditions in a sequence, and they all must be mutually-exclusive. We usually reserve switch statements for when there are many conditions to test for, but in Fusion it's the only alternative for an IF/ELSE. Now I know what to aim for - thank you!

    Now back to trying to figure out how to detect the end of a physics simulation. If I loop all boxes checking if the speed is zero, would that loop stop when it finds the FIRST box with zero speed, or would it keep checking for all the others? I ask because in most programming languages, a loop stops when the condition is met. How is that in Fusion?

  7. #7
    Clicker Fusion 2.5Fusion 2.5+ DLC
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    643
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    As far as I know, it will loop through all boxes and scope all of them that meet that condition.

  8. #8
    Clicker Install Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Ken1171's Avatar
    Join Date
    Sep 2016
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just wanted to thank you guys for the help. I just got started with Fusion and I am getting the hang of it pretty quickly. I guess the way loops and scope work got me off guard at first, but things are going well now.

Similar Threads

  1. Replies: 3
    Last Post: 18th January 2015, 09:05 AM
  2. Replies: 16
    Last Post: 16th July 2014, 08:59 AM
  3. Movement synchronization issues (physics spaceship movement)
    By SecondSons in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 24th January 2014, 10:52 PM
  4. Physics question! Making AI that uses Physics Platformer/Physics Static movement
    By Krim in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 13th December 2013, 03:19 AM
  5. Platform Movement Object - cannot detect 2 objects
    By pinacoladaxb in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 11th April 2008, 03:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •