User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14

Thread: Some strange behavior with DJFuegos custom sine movement

  1. #1
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Apr 2012
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Some strange behavior with DJFuegos custom sine movement

    Greetings!

    I've implemented the custom sine movement that DJ Fuego supplied in this thread http://community.clickteam.com/threads/54175-Custome-sine-movement

    I've applied this to a platform that moves vertically, and I've encountered a strange behavior.

    My game runs in fullscreen, resolution 480x270. I'm only changing the Y position of the platform.

    The formula for moving the platform is
    Set Y position of verticalPlatform to

    initalY( "verticalPlatform" ) + 30 * Cos(2) * yTimer( "verticalPlatform" )) * 3.14

    This is done in a fastloop, and in the same fastloop, yTimer is increased by 1.
    This results in what appears to be a smooth sine movement up and down, but the problems arise when I stand on the platform and it makes the screen scroll up or down.
    It results in a perceived feeling of the platform "stuttering" as it nears the turning point of its movement. I checked step-by-step to see if there was any actual stuttering going on, like it going up and down in a millisecond or so, but I could spot no such thing. Any idea why this is? Is it just an optical illusion?

    As I mentioned, this is only noticeable when riding with the platform, not when standing still on the Y axis watching it go by.

  2. #2
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Apr 2012
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did some testing while changing it to Cos(1), and it appears there are some irregularities with the movement when its approaching the end of the path. Is this due to it calculating decimalpositions, resulting in it moving 1 and then 2 and then 1 again pixels?

    Edit: Did further testing, and it seems it's stuttering because it moves 2 pixels one draw, then 1 the next, then 2 pixels again. Any idea how to get around this?

  3. #3
    Clicker Fusion 2.5Fusion 2.5+ DLC
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    679
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    It's most likely a combination:

    1) Always store movements like this that use decimal positions in an alterable value, then set the y position of your object to that value. Instead of:

    Set Y position of verticalPlatform to initalY( "verticalPlatform" ) + 30 * Cos(2) * yTimer( "verticalPlatform" )) * 3.14

    you do:

    Set value "ypos" or something similar of verticalPlatform to initalY( "verticalPlatform" ) + 30 * Cos(2) * yTimer( "verticalPlatform" )) * 3.14
    Set Y position of verticalPlatform to Round(ypos("verticalPlatform"))

    If you don't use Round() then your position will be off because of inherent errors with floating point numbers and Fusion. You must store floats in values because XY position events can only accept integers, while alterable values can calculate with floats. If you attempt to do anything with floats using the XY positioning directly then your decimals will be discarded, ruining the expression.


    2) This will be the billionth time i've repeated this one (Clickteam really needs a stickied thread with some crucial information like this ): Always make sure that your camera event (that centers the screen) is BELOW any movement events. Putting it at the absolute bottom is the safest. Not doing this will cause stuttering most of the time, since if there is any movement after the camera has centered, the next time it attempts to center it will already be one frame behind and need to catch up, causing a lag. Remember that the event sheet is read from top to bottom.

  4. #4
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Apr 2012
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you immensly casleziro, I will attempt this and see how it goes

  5. #5
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Apr 2012
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So I tried this now, and sadly it's exactly the same. The camera events are at the very bottom, and I'm using the set y position to Round(ypos) but the stuttering is no different. Did I forget something else?

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Could you provide a small example showing the issue?
    (just platform + player + scrolling)

    Sometimes things get fixed in the process of "reducing" to smallest issue
    or else, others may take a look at what may be going wrong

    (a possible workaround regardless of the issue: you can have a separate "camera" always moving towards the player,
    you can make its speed constant to avoid any possible stutter)

  7. #7
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Apr 2012
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    verticalPlatTest.mfa

    Here is an example!

    To notice the stuttering, pause the game and go frame by frame in the debug. Note that the speed varies between 3 pixels per step, 2 pixels per step, 3 pixels per step.

  8. #8
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Apr 2012
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The stuttering is not caused by the camera from what I can see, but from the varying amount of pixels moved by the platform.

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    mmm I see what you mean
    but I think there's no escape from this
    as long as you want "sub-pixel" movements

    cos(or sin) can range from -1 to 1 and all floats inbetween
    thus your movements can be cos(xx)*(anynumber)
    since you gradually increase (xx)
    rounding this will abruptly result in "number" or "number +/-1"

    and so resulting movement will be 0 or 1
    (magnified to 2 or 3 or more)
    this will determine if the platform should move to next pixel or not

    I think if you want no jumps at all you should always add or subtract one whole pixel at least
    and only increase or decrease after you "shift" movement direction, until you shift direction again

    or, as suggested above, use an external camera and "smoothen" its movement independently from player position

    but I don't think this is a problem for many people..?

  10. #10
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Apr 2012
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for the help schrodinger, I'll ponder how to proceed

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Strange problem with physic plateform movement behavior
    By CrystalNoir in forum Fusion 2.5
    Replies: 0
    Last Post: 28th June 2014, 07:43 PM
  2. strange behavior for sub.app under swf
    By Fernando in forum SWF/Flash Export Module Version 2.0
    Replies: 5
    Last Post: 1st April 2011, 01:02 PM
  3. Strange Counter Behavior
    By drnebula in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 5th October 2008, 05:23 PM
  4. Strange Bounce behavior... help
    By Tuna in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 2nd October 2008, 04:13 PM
  5. Really Strange Group Behavior...
    By xerus in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 16th September 2007, 06:48 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
  •