User Tag List

Page 2 of 2 FirstFirst 1 2
Results 11 to 20 of 20

Thread: Cos and Sin math problem (custom 8 direction)

  1. #11
    Clicker Multimedia Fusion 2 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator ProFirefly 3D Module
    drnebula's Avatar
    Join Date
    Jul 2006
    Location
    Pennsylvania, USA
    Posts
    908
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Cos and Sin math problem (custom 8 direction)

    I've added an example in the file download section under widgets. There are two ships, one with the code that you have looked at and the 2nd with the code for multiplying the diagonals by 0.707.

    You can't just add the multiply by 0.707 directly because then there would be two events happening at the same time when you push the up and right buttons at the same time. One line of code would say do right and another would say do up and right.

    So the code gets more complicated - when you push a single button you have to negate the pushing of the other buttons at the same time.

    You can see the code - its in the behavioirs inside of the active object. You can find it at:
    http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=133345#Post1333 45

    Steve

  2. #12
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator ProFirefly 3D Module
    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
    Jul 2006
    Location
    USA
    Posts
    2,970
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Cos and Sin math problem (custom 8 direction)

    Okay, I tried using the widget, it does work. I coded my object using the same events and when placing the widget on top of my object, they move in sync, so they both are coded the same now.

    However, the movement in the widget doesn't appear to be correct. Allow me to explain.

    I placed the 2 widgets on top of each other, and even an active with built in 8 direction movement on top of those.

    The Home Made 8 direction movement moved in the right angles, but moved faster when going in angled directions because it didn't have the adjustment of 0.707. That's what I originally had and was trying to figure out how to correct. Note that the built in movement doesn't have this problem. But this is how the movement works because there is no adjusting for the angles, so that is not a problem with how you did your events, just the math of how the movement works.

    The widget with the 0.707 adjustment to correct this seems to have some problems of it's own, however.

    For some reason, when moving Down+Right it moves visibly slower than the other angles. What is really strange is that Up+Left seems to move just as fast as the one without any speed adjustment. Also, when moving Down+Left or Up+Right, the widget with 0.707 adjustment didn't move in a 45 degree angle it was slightly off.

    Sorry, I'm not trying to be rude and pick apart your widget, it just appears that it is incorrect and I'm trying to figure out why.

    The only reason I'm not using built in 8 direction is because I want to have more control over how the movement of the object behaves, but right now I'm having big problems getting it to even just move in the correct angles at the correct speed. And again, please note this happens with your widgets as well, not just my object that I made to match your widget movement, so it's not something I forget to put into my events.

    I'm about to the point where I'll just give up and use the built in movement.

    I'm not sure if it's a math rounding error in MMF2 or what the problem is. But to see what I mean, set all the objects on top of each other and adjust their speeds to match, and you will see the discrepancy in how they move.

    Basically, I want the 8 direction movement at the same speed regardless of direction and moving in the 45 degree angle increments. So far, I can't get that to work.

    Edit - if someone else would be kind and test out this widget as well, I'd appreciate it. Maybe we can get to the bottom of this.

  3. #13
    Clicker Multimedia Fusion 2 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator ProFirefly 3D Module
    drnebula's Avatar
    Join Date
    Jul 2006
    Location
    Pennsylvania, USA
    Posts
    908
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Cos and Sin math problem (custom 8 direction)

    Shawn,

    What you say seems to be correct, but I see no reason why there should be a difference. I tried coding sin(45) instead of 0.707, thinking that there was a round off error. But I got the same result. I'll keep thinking about it - maybe someone with more experience than I can explain what is happening.

    Steve

  4. #14
    Clicker Multimedia Fusion 2 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator ProFirefly 3D Module
    drnebula's Avatar
    Join Date
    Jul 2006
    Location
    Pennsylvania, USA
    Posts
    908
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Cos and Sin math problem (custom 8 direction)

    I simplified the code to remove as much as possible. I took out all of the animation and made each direction have the same graphic with the same x and y point. I removed all of the buttons except for the ones that go diagonally - 7 = up and left for example. The problem still persists. If you toggle back and forth between the 7 and 3 directions, the ship goes at 45 degrees and stays in place. If you toggle back and forth between the 9 and 1 buttons, the ship does not go at 45 degrees and slowly moves up and to the right. The code is so simple at this point, it would seem to be some kid of bug.
    Steve

  5. #15
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator ProFirefly 3D Module
    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
    Jul 2006
    Location
    USA
    Posts
    2,970
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Cos and Sin math problem (custom 8 direction)

    Quote Originally Posted by drnebula
    I simplified the code to remove as much as possible. I took out all of the animation and made each direction have the same graphic with the same x and y point. I removed all of the buttons except for the ones that go diagonally - 7 = up and left for example. The problem still persists. If you toggle back and forth between the 7 and 3 directions, the ship goes at 45 degrees and stays in place. If you toggle back and forth between the 9 and 1 buttons, the ship does not go at 45 degrees and slowly moves up and to the right. The code is so simple at this point, it would seem to be some kid of bug.
    Steve
    That's what I was thinking. I don't think it's anything wrong with the events. I think there is actually something buggy with how the movement is being calculated by MMF.

    I don't know, maybe Yves can look at it?

  6. #16
    Clicker Fusion 2.5 DeveloperFirefly 3D Module

    Join Date
    Oct 2006
    Location
    Finland
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Cos and Sin math problem (custom 8 direction)

    are you guys sure that the application doesn't register some movements twice or something? Like if you press up&right it registers "up+right" and "up" resulting it going more up than right. If it's something like that, you could put something like

    +pressed up
    +not pressed left
    +not pressed right

    -Set Y Coordinate of Player to Player's Y Coord - Speed*Sin(90)


    etc.

    ...ranging out the possibility, it accidentally plays two events the same time. I don't know if it'll work, but just an idea.

  7. #17
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator ProFirefly 3D Module
    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
    Jul 2006
    Location
    USA
    Posts
    2,970
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Cos and Sin math problem (custom 8 direction)

    Quote Originally Posted by Tomssuli
    are you guys sure that the application doesn't register some movements twice or something? Like if you press up&right it registers "up+right" and "up" resulting it going more up than right. If it's something like that, you could put something like

    +pressed up
    +not pressed left
    +not pressed right

    -Set Y Coordinate of Player to Player's Y Coord - Speed*Sin(90)


    etc.

    ...ranging out the possibility, it accidentally plays two events the same time. I don't know if it'll work, but just an idea.
    Yep, we already have that in the events, pretty much exactly what you posted. So, I have no clue what is going on.

  8. #18
    Clicker Multimedia Fusion 2 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator ProFirefly 3D Module
    drnebula's Avatar
    Join Date
    Jul 2006
    Location
    Pennsylvania, USA
    Posts
    908
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Cos and Sin math problem (custom 8 direction)

    Look at the latest example that I uploaded. In that example, there is only one button to go up and right, one button to go down and right, etc. I don't see how that can be duplicating the motions.
    Steve

  9. #19
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator ProFirefly 3D Module
    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
    Jul 2006
    Location
    USA
    Posts
    2,970
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Cos and Sin math problem (custom 8 direction)

    I don't normally like to "bump" posts, but seeing how this is a problem that was never solved, can someone investigate this? Check out the example files in the links above and see what I'm talking about.

    In the meantime I just went back to built in movement, but surely you can get the correct angles and speed with Cos and Sin in MMF2? Both drnebula and I cannot figure out why this didn't work.

  10. #20
    Clicker Fusion 2.5 DeveloperFirefly 3D Module

    Join Date
    Oct 2006
    Location
    Finland
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Cos and Sin math problem (custom 8 direction)

    Problem solved!

    filearchive post

    ...stupid me for not thinking about that earlier.

Page 2 of 2 FirstFirst 1 2

Similar Threads

  1. Custom 8 direction movement, problems with speed
    By Shawn in forum Multimedia Fusion 2 - Technical Support
    Replies: 11
    Last Post: 8th November 2013, 02:49 PM
  2. Math Challenge - no actual problem
    By Verd0uX in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 25th June 2009, 04:36 PM
  3. Custom 8 Direction Movement
    By JL32BiT in forum File Archive
    Replies: 1
    Last Post: 2nd July 2006, 06:08 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
  •