User Tag List

Results 1 to 3 of 3

Thread: Adapting Movement to Delta-time

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export Module
    Chrille's Avatar
    Join Date
    Jul 2006
    Posts
    389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Adapting Movement to Delta-time

    I've decided to implement delta-time to my game, but I can't think of a good way to adapt my current movement system to it and was hoping someone might have a solution.

    My character moves in a straight line from the starting point to the destination, the movement time is calculated by distance/character speed. Here's what the code for setting the screen coordinates look like:
    Code:
    Always:
    X = starting point.X + (moveDistance.X * (step / moveTime))
    Y = starting point.Y + (moveDistance.Y * (step / moveTime))
    step ++
    I went for this half-assed solution in lack of any better ideas:
    Code:
    + Always:
    - Counter = Counter + (30 * deltaTime)
    - X = starting point.X + (moveDistance.X * (step / moveTime))
    - Y = starting point.Y + (moveDistance.Y * (step / moveTime))
    
    + Counter is greater than 1
    - step ++
    - Counter = 0
    That solution works as long as I don't set the frame rate too low, but it doesn't feel like right way to go. Very grateful for any suggestions.

  2. #2
    Clicker

    Fusion 2.5 Developer
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    J3sseM's Avatar
    Join Date
    Feb 2013
    Location
    Finland
    Posts
    868
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The way I do it is that I have two global values, one I call: deltaspeed and one is deltatime.

    Always -> set deltatime to (deltaspeed/1.0)/(framerate/1.0)
    Basically I can now adjust the speed of the game with deltaspeed (as long as I use deltatime in my code)

    My character has a value pos_x and I have an event:

    Always -> set position x to pos_x

    And when I move I simply do: Add 3*(deltatime*60) to pos_x

    My framerate is 60. This works really well even with LOW fps as it always adds to value.

    Not sure if you can use this somehow but thought I'd share it anyway!

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export Module
    Chrille's Avatar
    Join Date
    Jul 2006
    Posts
    389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for sharing. I use an example that tompa shared, with the formula of:

    + Always
    - deltatime = (timer - timerLastValue) * 0.001
    - timerLastValue = timer

    I realised I could use "step = step + (deltatime *30)" instead. Well, I had some problems since I'm storing all the values in an array, and it doesn't support float variables. I had to multiply the value added by 1000 when writing, and dividing by 1000 when reading. It works quite well now, but it still chops along quite inconsistently at lower frame rates. Not that I'm aiming for it to ever drop down below 20

Similar Threads

  1. Adapting Timonthy Lottes' CRT Shader?
    By BlazeHedgehog in forum Fusion 2.5
    Replies: 0
    Last Post: 5th March 2015, 05:07 AM
  2. Custom Delta Time Accelerated Movement with Move to Function
    By rocketappliances in forum Fusion 2.5
    Replies: 1
    Last Post: 3rd March 2015, 02:04 AM
  3. Replies: 3
    Last Post: 12th November 2014, 09:15 PM
  4. Delta Time acting wierd?
    By Outcast in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 22nd November 2013, 02:54 AM
  5. Correct way to calculate a delta time on MMF?
    By BHGames in forum iOS Export Module Version 2.0
    Replies: 5
    Last Post: 3rd July 2011, 03:28 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
  •