User Tag List

Results 1 to 6 of 6

Thread: Custom topdown movement problem.

  1. #1
    Clicker Fusion 2.5 (Steam)
    TTK's Avatar
    Join Date
    Dec 2018
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Custom topdown movement problem.

    So i tried making a custom 8-directional movement, the problem is with the diagonal movement. Up right and down left workes fine, but up left is much faster and down right is 2 times slower than up right.
    Attached files Attached files

  2. #2
    Clicker Fusion 2.5Fusion 2.5 Mac
    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)Universal Windows Platform Export Module (Steam)
    zip2kx's Avatar
    Join Date
    Jun 2015
    Posts
    781
    Mentioned
    17 Post(s)
    Tagged
    0 Thread(s)
    Simplest way is to do a manual check if the key combinations to go diagonal is pressed and then cut the speed value in two.

  3. #3
    Clicker Fusion 2.5 (Steam)
    TTK's Avatar
    Join Date
    Dec 2018
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not really because the value isn`t two times the normal but something around 4/3 (up and left) and the other one 2/3 (down and right). Besides i mainly want to know why that happens.

  4. #4
    Clicker Fusion 2.5 Mac
    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)Universal Windows Platform Export Module (Steam)

    Join Date
    Jan 2015
    Location
    Australia
    Posts
    170
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Adding/removing to an object's X/Y position with a decimal point in Fusion always seems to round it "down" to a the lowest number.

    (More accurately, it "floors". That means Floor(1.5) and Floor(1.9) both equal 1, but Floor(-1.5) 'rounds' down to -2.)

    If you set an object's X position to X+1.5 every frame it will move exactly 1 pixel to the right every frame, but if you move it X-1.5 every frame it will move it 2 pixels to the left since it will floor down the value. The same goes for adding/subtracting to Y, it will always floor any integer you. Basically, the X/Y position is always an integer (no decimals) and not a float (can have decimals)

    That means if you did want the object to accurately move diagonally at the correct speed using trig/Sqr decimal values, you can instead set aside some alterable values to store the "real" X/Y position as a float, and set the objects X/Y position to that value instead.

    Here's a short example that I hope makes sense:
    subpixel movement.mfa

    The Blue object (Active 1, on the top) moves at 1.5 pixels per frame by adding to the X position. Moving left is faster than moving right as it floors -1.5 down to 2 when moving left, and floors 1.5 to 1 when moving right

    The Red object (Active 2, in the middle) moves at -2 pixels left and -1 pixels right. Its speed is exactly the same as the blue object even though we're moving it by a different amount

    The Pink (Magenta? Active 3, on the bottom) stores it's current X/Y position at the start of the frame and simply adds/removes 1.5 to that. Since it's an alterable value it can store decimals (which the object uses as it's X/Y position on screen) and moving left/right is the same speed

  5. #5
    Clicker Fusion 2.5 DeveloperiOS Export Module
    butterfingers's Avatar
    Join Date
    Apr 2012
    Location
    London
    Posts
    135
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Marbenx, thanks for that, I was looking at the MFA above and couldn't figure out what was wrong, interesting to know that the rounding works that way. Cheers

  6. #6
    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)
    You could alternatively set a "move angle" value that is whichever direction the player is holding (0 for right, 180 for left, etc) and base the player's velocity on cosine ( x = x*cos(angle), y = y*(0-sin(angle)) ).

    If you want a quick fix, I believe multiplying your velocities by 0.717 is the most accurate number for diagonals.

Similar Threads

  1. Custom Smooth Screen Scrolling Effect Topdown
    By Shadeve in forum Fusion 2.5
    Replies: 11
    Last Post: 10th July 2017, 05:13 PM
  2. Whats the best movement for a topdown shooter?
    By Camomano99 in forum Developer Services
    Replies: 2
    Last Post: 20th November 2016, 05:59 PM
  3. fastloop topdown movement example
    By Bigfoot in forum File Archive
    Replies: 0
    Last Post: 15th April 2011, 01:34 PM
  4. TopDown Custom Movement Help
    By Sumo in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 16th September 2009, 07:18 PM
  5. Custom Movement problem (Horizontal movement)
    By KiteRyagara in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 7th June 2008, 03:40 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
  •