User Tag List

Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 21

Thread: Moving platform collisions (solved!), but just one question!

  1. #11
    Clicker Multimedia Fusion 2Android Export ModuleiOS Export Module
    loglady's Avatar
    Join Date
    Jul 2011
    Location
    Twin Peaks
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @Yima
    Just to add, I tested on Windows XP (running on a bootcamped Mac Mini). Tried on a Core 2 Quad (Q6600), 4gb ram, Radeon HD5700 and had the very same issue.

  2. #12
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Yima's Avatar
    Join Date
    Feb 2008
    Location
    Sweden
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe I know what might be the issue, but I have not tested it yet (I am at work).

    All movement is made using fastloops. Movement is not made directly by pixel, but rather on a grid that is higher resolution than the actual screen. In the example posted, that resolution is 10 times higher than the resolution on screen. As it is now, collisions are checked each time a movement on the grid is made. This is not neccessary, I believe. It would be enough to do collision checks only during loops in which an actual pixel movement is made. Each collision check triggers a loop through all moving platforms, and as we all (should) know, nested loops are dangerous for performance.

    I'll illustrate how it works right now:

    The game has a resolution grid that is 10 times the actual screen resolution. This means that 10 movements on the grid is needed to move one pixel on the screen.

    cc = collision check
    pm = pixel movement
    ypos = y position on the grid

    The y speed of the player (I believe, can't check right now) is set to 28, meaning we perform 28 y movements per game loop.

    Game loop 1

    (First we make a collision check, to see if we should stop the player from falling (if he lands on the ground or a moving platform) or going up (if the player hits the roof). Then a movement on the grid is made.)
    (cc)(ypos+1)
    (cc)(ypos+1)
    (cc)(ypos+1)
    (cc)(ypos+1)
    (cc)(ypos+1)
    (cc)(ypos+1)
    (cc)(ypos+1)
    (cc)(ypos+1)
    (cc)(ypos+1)
    (cc)(ypos+1)(pm) < This is where the pixel movement is made, and it's actually only here we need to check for collisions.
    (cc)(ypos+1)
    (cc)(ypos+1)

    ...and so on

    For each cc in the list above, a second loop triggers, which goes through all active objects that act as platforms (moving platforms, conveyors, springs and so on). If I limited collision checks to only the instances where pixel movements will be made, I would be able to remove 9 times 9 times (number of platforms) loops per game loop (9 x movements, and 9 y movements) . This can easily amount to over 1000 less fastloops per game loop when there are many platforms in one place.

    To add to this, the same type of checking is done each time a platform moves on the grid, so there is lots to save there as well.

    It would be interesting to know if someone with experience could comment on this. I'd like to know if I can gain a lot of performance by doing the changes I am proposing above.

    For anyone that is interested in why I am using a grid at all, and don't move by pixels directly, it's because I make games with rather low resolution. Without using a grid, it's almost impossible to get smooth movement (such as platforms moving in a circle, or the player accelerating to max speed).

  3. #13
    Clicker Multimedia Fusion 2Android Export ModuleiOS Export Module
    loglady's Avatar
    Join Date
    Jul 2011
    Location
    Twin Peaks
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This makes me remember when I was prototyping a 3D game to run on a 1st generation iTouch. The games wasn't simple but ran flawlessly after the programmer discovered that he was checking for collisions on every game loop. The frame rate was always lower than 20fps. After checking for collisions only inside the area where a collision could happen, the game stood nicely on 60fps without slowdowns. Sure, the game wasn't a platform game but it was just to show that sometimes we want to guarantee that everything runs fine but end up doing some "overkill". If you allow me, take a full look at this thread ( http://community.clickteam.com/threads/80687-DavidN-s-Fastloop-custom-movement-question-%28horizontal-speed%29 ) and you can find an example on page two to work with fractionated values. I'm using it for low resolutions. By the way, I'd like to see how you are doing this "grid movement".

  4. #14
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My question is if there is anyone else that has run into similar issues when creating moving platforms using fastloops? I am curious as to why overlap checks does not seem to work reliably in these situations. I would really love it if detectors worked, since they generally produce less code.

    Hi Yima
    I have, in frustration, encountered this problem many times

    Long story short, the B Objects Collision 'Mask' ( you have no controll over this mask ) in a Collision/ Overlap Event lags by 1 Frame.
    I dont know 'why' it is like this, but this ^ is the way it is.
    In my opinion you are wize to use Position coordinates to get accurate collision detection, although this works only with Active Objects as Obstacles ( without any kind of loops ).

  5. #15
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Yima's Avatar
    Join Date
    Feb 2008
    Location
    Sweden
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by loglady View Post
    This makes me remember when I was prototyping a 3D game to run on a 1st generation iTouch. The games wasn't simple but ran flawlessly after the programmer discovered that he was checking for collisions on every game loop. The frame rate was always lower than 20fps. After checking for collisions only inside the area where a collision could happen, the game stood nicely on 60fps without slowdowns. Sure, the game wasn't a platform game but it was just to show that sometimes we want to guarantee that everything runs fine but end up doing some "overkill". If you allow me, take a full look at this thread ( http://community.clickteam.com/threads/80687-DavidN-s-Fastloop-custom-movement-question-%28horizontal-speed%29 ) and you can find an example on page two to work with fractionated values. I'm using it for low resolutions. By the way, I'd like to see how you are doing this "grid movement".
    This sounds promising, as it means I can probably reduce the amount of collision checks by a tremendous amounts. I am rewriting the engine right now, so I will definitely keep this is mind when solving the platform stuff.

    As for how the resolution grid movement works, I am at work right now, and thus I can't post an actual game example. I have however drawn a image to illustrate how it works (attached).

    The concept is that instead of moving a character or platform directly by pixels, we introduce a grid that has higher resolution than the actual screen. In the current iteration of my engine, I work with a resolution of 160 x 144 pixels (gameboy resolution), but the movement is made on a grid that has 10 times as high resolution (1600x1440 positions). So, movement is made on the grid, and is then translated into a pixel position by dividing the xpos and ypos variables (which keep track of the position on the grid) by the grid resolution (10 in this case).

    The advantage of this solution is that you can make "sub pixel" movements, that results in smoother gameplay. Without the grid, we are restricted to either moving an object one pixel, or don't moving an object one pixel - there is no in between. This binary situation becomes extra problematic when we are dealing with accelerating movements or fine arc movemenets over a limited space (I illustrate the circular movement in the attached picture).

    resolution grid movement.jpg

  6. #16
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Yima's Avatar
    Join Date
    Feb 2008
    Location
    Sweden
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by King_Cool View Post
    My question is if there is anyone else that has run into similar issues when creating moving platforms using fastloops? I am curious as to why overlap checks does not seem to work reliably in these situations. I would really love it if detectors worked, since they generally produce less code.

    Hi Yima
    I have, in frustration, encountered this problem many times

    Long story short, the B Objects Collision 'Mask' ( you have no controll over this mask ) in a Collision/ Overlap Event lags by 1 Frame.
    I dont know 'why' it is like this, but this ^ is the way it is.
    In my opinion you are wize to use Position coordinates to get accurate collision detection, although this works only with Active Objects as Obstacles ( without any kind of loops ).
    I am seriously considering ditching the collision by pixel solution altogether, and try to define the backgrounds mathematically instead. This way, all collisions would be done by comparing positions, rather than hoping that the objects I moved in a fastloop actually are where there are supposed to be. Doing this without slopes is not hard, but with slopes it becomes trickier. I'll try to come up with something.

  7. #17
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Yima's Avatar
    Join Date
    Feb 2008
    Location
    Sweden
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by salamanderpants View Post
    This sounds interesting. Will you be releasing any example of this grid movement in the future?
    Yes, I will likely release a stripped down version of the engine I am making my current game in.

  8. #18
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Yima View Post
    This sounds promising, as it means I can probably reduce the amount of collision checks by a tremendous amounts. I am rewriting the engine right now, so I will definitely keep this is mind when solving the platform stuff.

    As for how the resolution grid movement works, I am at work right now, and thus I can't post an actual game example. I have however drawn a image to illustrate how it works (attached).

    The concept is that instead of moving a character or platform directly by pixels, we introduce a grid that has higher resolution than the actual screen. In the current iteration of my engine, I work with a resolution of 160 x 144 pixels (gameboy resolution), but the movement is made on a grid that has 10 times as high resolution (1600x1440 positions). So, movement is made on the grid, and is then translated into a pixel position by dividing the xpos and ypos variables (which keep track of the position on the grid) by the grid resolution (10 in this case).

    The advantage of this solution is that you can make "sub pixel" movements, that results in smoother gameplay. Without the grid, we are restricted to either moving an object one pixel, or don't moving an object one pixel - there is no in between. This binary situation becomes extra problematic when we are dealing with accelerating movements or fine arc movemenets over a limited space (I illustrate the circular movement in the attached picture).

    resolution grid movement.jpg
    Although the idea sounds original, i cant help but think you are overcomplicating things.

    Wouldnt it be easier to just use Alteterable Values as X and Y coordinates ( as theese can store floats )?
    That way you can have decimal coordinates and decimal speeds/ variables.

  9. #19
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Yima's Avatar
    Join Date
    Feb 2008
    Location
    Sweden
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by King_Cool View Post
    Although the idea sounds original, i cant help but think you are overcomplicating things.

    Wouldnt it be easier to just use Alteterable Values as X and Y coordinates ( as theese can store floats )?
    That way you can have decimal coordinates and decimal speeds/ variables.
    The reason I do this is that I want to make sure that the player's speed is always a whole number. If the player's speed is a float number, and float numbers are added and reduced from it (rather than always adding or subtracting 1 from a whole number), there is a risk that the speed will flip back and forth from negative to positive, rather than ending up at 0 when the player is stationary. Basically, any system where all positions and speeds are integers, rather than floats, will be much less prone to end up causing weird errors due to float divisions and such. I admit that I might be overly cautions due to ineperience, but I'll employ other methods when I can safely work with them

  10. #20
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Yima's Avatar
    Join Date
    Feb 2008
    Location
    Sweden
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I created a thread where I link my platform engine, if anyone is interested

    http://community.clickteam.com/threads/82063-Styrbjorn-s-platform-engine?p=602196#post602196

Page 2 of 3 FirstFirst 1 2 3 LastLast

Similar Threads

  1. SOLVED: Full Screen Touch for Standard Jump Button (w/o Platform Movement Object)
    By lokanientertainment in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 7th October 2013, 11:22 PM
  2. 2 Platform Movements overlapping on a moving platform
    By SuperDisk in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 1st July 2013, 11:20 PM
  3. Moving Platform in Platform Movement Object
    By radel999 in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 16th July 2012, 01:49 PM
  4. Newbie Stuff, Collisions, Moving Animations
    By XenonMB in forum Multimedia Fusion 2 - Technical Support
    Replies: 17
    Last Post: 22nd February 2007, 07:41 PM
  5. Moving with numbers (solved)
    By Jason in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 19th July 2006, 11:45 AM

Posting Permissions

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