User Tag List

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

Thread: Why is object moving passed the walls?

  1. #1
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,308
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    Why is object moving passed the walls?

    Using the floating point movement as the base. I noticed if the speed of the object is too fast, the object goes 'passed' the walls. Shouldn't it still hit the wall, no matter what the current speed of the object is?

    Here's the mfa of what I'm talking about.

  2. #2
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export ModuleUnicode Add-on
    Looki's Avatar
    Join Date
    Aug 2006
    Location
    Karlsruhe, Germany
    Posts
    3,741
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: Why is object moving passed the walls?

    Of course not.

    Imagine this scenario:

    A 1 pixel big object moves at 5 frames per frame.

    Its starting X position is 0.

    Theres a 1px thin vertical wall at X position 12.

    Frame 0: Object's X is 0.
    Frame 1: Object's X is 5.
    Frame 2: Object's X is 10.
    Frame 3: Object's X is 15.

    Since the object never overlaps the wall, there's no colision. It kind of "jumps over" it.

    To fix this, you could use fast loops.
    Run a loop X times every frame, X being the X velocity.
    Every loop, you move the object either one pixel to the left or to the right (only the MMf position, not the float one), depending on the velocity. If the object overlaps a wall (put the loop condition above), stop the loop and update the float X position. Same goes for Y.

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,308
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    Re: Why is object moving passed the walls?

    Well I checked DavidN's fastloop tutorial. But that doesn't help me with this method of movement. His fastloop tutorial gives an absolute value and relies on actual X position of object. While mine pretty much relies on the floats, or alterable values for the position, making sure the floats remains the position of the object.
    I tried adding fastloops in the mix, but it just seemed to mess up, no matter what I do. X_X

    EDIT: Okay, I added fastloops, but it doesn't 'feel' the same as using the events without them.
    What is abs()? Does that mean absolute value or something? Wouldn't that effect the floats to become absolute value? In other words, round up or down?
    Is there an opposite for abs()? One of these things that still makes use of floats? Because when I use 'abs(Value A("Active")) Times' for the fast loop, it seems to round it. I still want to use the floats.

    Apparently there is a difference between
    'Start Loop "move-x" abs(Value A("Active")) Times' - (Where value A is named Velocity
    and
    'Start loop "move-x" 1 times'


  4. #4
    No Products Registered

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Why is object moving passed the walls?

    Of course there will be a difference between the 2. Unless your velocity is only 1 then it will be different.

    Abs() makes a number always positive.
    So for example abs(-19485) will turn into 19485.
    As far as I know you can have decimals with abs, it doesnt do any rounding at all, merely makes sure you never have a negative number.

    Ceil() and Floor() are used to round values.

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,308
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    Re: Why is object moving passed the walls?

    But when I use fast loops, and abs() function for the number of times to do the fast loop, it seems like it's rounding the velocity or position anyway. When the display says that Velocity X is still over 0 (ex. 0.56789), the object does NOT move at all. It only moves when the velocity is 1, or over 1.
    When I remove the fast loop function, the object moves even at 0.56789, like I want (with the exception that the object still passes through the walls at full speed). But it does NOT move at Velocity x at 0.56789 when I use fast loop? This is weird. Explanation? X_X

    EDIT: I updated the MFA on the link at top. I included two frames in it. One without the fast loops, and one with the fast loops. It seems like it makes the object move faster when I use fast loop? That is not right. They are supposed to move at the same speed. X_X

  6. #6
    No Products Registered

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Why is object moving passed the walls?

    Well you cant run a loop 0.56789 times, thats why.

    Abs() doesnt do any rounding. Fastloops can only be run in full digits, so it will round the decimal values (sounds like its rounding them down).
    You may need to use Ceil() in your case to make sure that values are rounde up (if thats what u want)

    I think you are a bit confused as to how this works. You want to call a fastloop the number of pixels that are going to be moved each step. On each loop you move the object 1 pixel in the direction and test for a collision.
    If no collision exists you keep going. If a collision then you stop the loop as this means you hit a wall.
    Thats the basic concept of it all.

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,308
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    Re: Why is object moving passed the walls?

    So, fast loops can't use decimals, or floats? o_O
    The deceleration & position will always vary depending on the current # the velocity and position shows. Using fast loops makes the object move faster than I want.

    I want to be able to move the same speed like in the first frame, but still use fast loops to prevent the object from passing through the walls using the current speed & position. X_X

  8. #8
    No Products Registered

    Join Date
    Sep 2006
    Location
    Germany
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Why is object moving passed the walls?

    You can't loop for 0,645 times. Fastloop perform in steps. A step is a solid number from 0 to whatever you choose. I think you misunderstood the concept behind it. Please check out the tutorial at: http://www.clickteam.com/website/usa/img/uploads/tutorials/download/fastlooptutorial.zip

    It explains how to use the loops and even comes with an example on how to push objects out of walls if they overlap. That is the only thing you need to add to your code and it will work for sure.

  9. #9
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,308
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    Re: Why is object moving passed the walls?

    But my point still remains. My Velocity and Position uses floats/decimal points. And fast loops doesn't handle numbers in floats/decimal points. The fast loop tutorial won't help much if the object moves passed the walls, since it doesn't technically overlap them. Not to mention it doesn't show an example of using alterable values with decimal points/floats under fast loops. So my code would still make the object move passed the walls due to an oversight in using floating point movement. X_X

  10. #10
    Forum Moderator Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleSWF Export Module
    DavidN's Avatar
    Join Date
    Jun 2006
    Location
    Boston, MA, USA
    Posts
    4,044
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Why is object moving passed the walls?

    An object can only have a location that's an integer number of pixels - the actual position of the object in your movement is an approximation to the nearest whole number to your X and Y position variables (check the position of it in the debugger). The number of times that a fastloop is run is an approximation of the velocity, in the same way - you can't run a fastloop a fraction of the time. (And you need to move the object a pixel at a time during the fastloop up to (velocity) times, not moving it by that velocity each time the fastloop is run).

    My platform tutorial deals with floating point velocities, but just uses the actual X and Y positions for the position. I think it would be possible to adapt it so that you kept track of the floating point positions as well outside the concept of looping, but I don't know if that would give you a noticeable advantage, X, underscore, X.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Ok, a lot of years have passed but still some problems in the Library Objects?
    By AftPeakTank in forum Multimedia Fusion 2 - Technical Support
    Replies: 13
    Last Post: 28th May 2013, 09:07 PM
  2. Bug: Why is my Object moving?
    By King_Cool in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 22nd March 2012, 08:28 AM
  3. Can global values be passed through counters?
    By Apex in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 3rd February 2012, 07:51 PM
  4. Attach active object to a moving object and follow
    By Worf in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 9th January 2010, 06:50 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
  •