User Tag List

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

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

  1. #1
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    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
    Aug 2006
    Location
    USA
    Posts
    2,982
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Cos and Sin math problem (custom 8 direction)

    Okay, well I'm still trying to fix my 8 direction movement.

    I guess I'm not understanding the Cos and Sin math right? The problem is that the character appears to be moving at angles faster than up, down, right, left. Here's what I have going on:

    Repeat While Moved Right
    * X( "Player Movement" )+Player Speed*Cos(0)
    * Y( "Player Movement" )-Player Speed*Sin(0)

    And so on for each direction (replacing 0 with the appropriate angles.

    What am I doing wrong? Yes, I know I'm not good at math :P

  2. #2
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    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
    Aug 2006
    Location
    USA
    Posts
    2,982
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

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

    To clarify "Player Movement" is the player object, and Player Speed is a global value for adjusting the speed of the player (obviously).

  3. #3
    Clicker Multimedia Fusion 2 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    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,
    I'm not entirely sure I understand what you are trying to do, but I will upload a screen from a game I'm working on called Asteroids (perhaps later to be called ROIDS. I've got a space ship that you can accelerate in the direction you are pointing and there are counters that calculate the x and y acceleration, velocity, and distance. It's a little cluttered since I've been playing with a number of other possible options, but it might help you get what you want to do done.
    Steve

  4. #4
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    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
    Aug 2006
    Location
    USA
    Posts
    2,982
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

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

    Quote Originally Posted by drnebula
    Shawn,
    I'm not entirely sure I understand what you are trying to do, but I will upload a screen from a game I'm working on called Asteroids (perhaps later to be called ROIDS. I've got a space ship that you can accelerate in the direction you are pointing and there are counters that calculate the x and y acceleration, velocity, and distance. It's a little cluttered since I've been playing with a number of other possible options, but it might help you get what you want to do done.
    Steve
    Well, what I'm just trying to create a basic 8 direction movement. Similar to the built in one, but just so I can customize it more.

    But here's what I have so far, in a better explanation:

    I have:

    Repeat while holding left:
    Set X coordinate of Player to Player's X Coord + Speed * Cos(180)

    Repeat while holding right:
    Set X coordinate of Player to Player's X Coord + Speed * Cos(0)

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

    Repeate while holding Down
    Set Y Coordinate of Player to Player's Y Coord - Speed * Sin(270)

    These events let me move in 8 directions, but it's not calculating the angles right and I don't know how to do that. Unless I'm hallucinating, it seems like when I move in the angled directions, you move just a bit faster. I tried solving this a while back but got stuck.

    I tried adding the 45 degree angles for up+right etc. but that just created even more problems.

  5. #5
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    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
    Aug 2006
    Location
    USA
    Posts
    2,982
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

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

    Well i've been reading about vectors and things online, and I read something about how I'm supposed to be using radians and not degrees with cos and sin? I have no idea how to do that in mmf.

  6. #6
    Clicker Multimedia Fusion 2 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    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)

    The sin and cos funtions in MMF work just fine with degrees. No need to mess around with radians.
    Steve

  7. #7
    Clicker Multimedia Fusion 2 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    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 don't have time to look at this right now, but for the Repeat while holding left, it would be: SEt X coordinate of Palyer to Players X Coord + Speed (no Cos(180) needed). For the four up, down, right, and left, just take out the sin or cos. They are not necessary. You only need the sin(45) when you are moring in both directions simultaneously.
    Steve

  8. #8
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    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
    Aug 2006
    Location
    USA
    Posts
    2,982
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

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

    Okay cool thanks! I'll start messing around with it when I get some time and see what happens lol.

  9. #9
    Clicker Multimedia Fusion 2 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    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 put an example of a home made 8 direction motion compared to MMFs 8 direction motion and they are pretty much identical.

    Now, if you push the right and up buttons, the object will go both right and up at the same speed, which is not what would happen in the "real" world. If that is what you want, then you would need to change the speed in all of these directions to sin(45)=cos(45)=0.707*speed.

    Hope this helps.

    Steve

  10. #10
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    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
    Aug 2006
    Location
    USA
    Posts
    2,982
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

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

    Yes, I'm trying to get the object to not travel faster when going in angles, which means I'm going to have to multiply by 0.707.

    However, I need some clarification of this line:

    "sin(45)=cos(45)=0.707*speed"

    I tried multiplying the speed by 0.707 for the angled directions and it produced weird results.

    At this point, I have the 8 directions working, I just need the vector movement right, which is where the 0.707 comes into play. I'm apparently not putting the expression in correctly in MMF.

Page 1 of 2 1 2 LastLast

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, 03:49 PM
  2. Math Challenge - no actual problem
    By Verd0uX in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 25th June 2009, 05:36 PM
  3. Custom 8 Direction Movement
    By JL32BiT in forum File Archive
    Replies: 1
    Last Post: 2nd July 2006, 07: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
  •