User Tag List

Results 1 to 3 of 3

Thread: Problem with sinewave y position

  1. #1
    Clicker Fusion 2.5
    Warmachine's Avatar
    Join Date
    Nov 2009
    Location
    Charleston, WV
    Posts
    664
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Problem with sinewave y position

    Here's my problem i have an enemy that i have working with a horizontal sinewave movement, that works perfectly. The problem is, i have a vertical frame that will have the player starting at the bottom and working his way to the top, and i need these enemies to be spread throughout. I've tried making them spawn randomly on the left and right edges of the frame and have unticked the follow the frame option and was able to get it to work once, but noticed that when the y movement of the player goes upward, the enemies follow. So i was thinking just making spawn objects in different spaces would solve the problem, but using the sinewave option only lets me set 1 "Final Y" and i dont know how to adjust the way to match the y of the spawn object. Does anyone know of a way to set the way to pair up the final y of the sinewave objects with the spawn objects?

  2. #2
    Clicker Fusion 2.5
    Warmachine's Avatar
    Join Date
    Nov 2009
    Location
    Charleston, WV
    Posts
    664
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Probably not the best way to go about it but i found a work around. I created different spawn points, cloned my enemies and assigned them to each individual spawn points with different final y conditions for each.

  3. #3
    Clicker Multimedia Fusion 2SWF Export Module
    Jacob's Avatar
    Join Date
    Jul 2007
    Location
    Second pixel to the right
    Posts
    3,208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I recommend learning how to set up your own sinewave movements. Dines has an excellent article on the subject, while Eliyahu has an elaborate tutorial for all things trigonometric.

    To sum it up concisely, Sin() and Cos() are functions that deal with angles. The number that goes inside it will only ever be an angle. It wraps from 0 to 360, so Sin(0), Sin(360), and Sin(720) all have the same value while Sin(180) and Sin(450) also share the same value. Depending on the value, the functions each return a value from -1 to 1, in a wave shape (this is why it loops every 360). The important thing to remember is that Cos() deals primarily with the X axis and Sin() with the Y axis. Look at this circle, where 0 degrees is on the right edge of the circle, 90 is the top, 180 is the left, and 270 is the bottom.


    Understanding that Cos() is the X axis, you can see that
    Cos(0 degrees) = 1
    Cos(90 degrees) = 0
    Cos(180 degrees) = -1
    Cos(270 degrees) = 0

    Since Sin() is the Y axis, Sin(90) is 1 and Sin(180) is -1 (and it's 0 at 0 and 180)

    The use of this is that you can offset positions by this oscillating value. 32*Cos(x) will return 32 when x = 0 and -32 when x = 180. You could make a formula like X = 320 + 64*Cos(angle) which will make your object oscillate horizontally left and right as you increase angle. If you use the same formula but swap out X for Y and Cos() for Sin() you will get a circle motion, HOWEVER

    Look back to the graph image above. It shows 1 as being the top edge of the circle, and -1 as being the bottom edge of the circle. This is normal in standard coordinate spaces. But MMF treats 0,0 as the TOP left instead of the BOTTOM left, which means negative values go up and positive values go down. When you are using Sin() with Y, you need to use negative Sin() instead.

    Always:
    Set X = 320 + 64*Cos(angle)
    Set Y = 240 - 64*Sin(angle)
    Add 1 to angle

    Would then be your final formula for moving an active around point (320,240) in a circle with radius 64. If you changed the radius of X but not Y or vice versa, you will get an oval shape. Change the radius of one to 0 and it won't move in that dimension at all, giving you linear oscillation.

    Final Formula:

    Set X = CenterX + Radius*Cos(angle)
    Set Y = CenterY + Radius*Sin(angle)

    Remember, Sin and Cos only deal with angles, and you multiply by how much you want them to move.

Similar Threads

  1. Sinewave movement problem?
    By ASD in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 7th February 2013, 12:07 PM
  2. Object Position Problem - Need Help
    By harlekin in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 20th November 2011, 03:48 PM
  3. position problem
    By Warmachine in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 17th June 2011, 06:51 PM
  4. Position Controller Help File Problem
    By droberson in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 25th March 2010, 07:43 PM
  5. Sinewave movement problem
    By pnekdo in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 22nd August 2009, 07:55 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
  •