User Tag List

Results 1 to 8 of 8

Thread: Need help making a shot arrow rotate mid-air based on its speed!

  1. #1
    Clicker Fusion 2.5

    Join Date
    Dec 2012
    Location
    Rhode Island USA
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help making a shot arrow rotate mid-air based on its speed!

    So I'm working on an archery engine learning from the only decent tutorial I could find, but the problem is that he uses Direction to make the arrow rotate mid-air.

    The rotation of the arrow itself is quite realistic (starts pointing down as it loses speed etc.). The problem with this is that there are only 32 directions, so it looks very choppy as it rotates. I want to use a pure angle-based method but I can't figure it out.

    The line of code he uses to do this is as follows:

    > Always
    > Set arrow direction to:
    (ATan((0-yVelocity( "arrow" ))/xVelocity( "arrow" ))/360)*32

    I'm not at all good with trigonometry, can anyone suggest something?

    Thanks >.>!

  2. #2
    Clicker Fusion 2.5

    Join Date
    Dec 2012
    Location
    Rhode Island USA
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay I actually figured this out finally. What I did was experiment with the code and I found that this does exactly what I wanted:

    (ATan((0-yVelocity( "arrow" ))/xVelocity( "arrow" ))+360)

    Posted the solution in case anyone else was wondering. Super smooth arrows now, yay.

  3. #3
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleiOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)
    ratty's Avatar
    Join Date
    Apr 2012
    Posts
    1,165
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Nice!

  4. #4
    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)
    Simply ATan((0-yVelocity( "arrow" ))/xVelocity( "arrow" )) will work. For those who don't know, this is taking y/x which is the formula for slope, and applying arcTan which converts it to degrees. The Y is negative in the formula because MMF treats 0,0 as the top left corner whereas the trig functions treat it as the bottom left — it has to be reversed so that an increase in Y is down rather than up.

  5. #5
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,341
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    That won't actually work for all angles - you need to use ATan2() instead.
    ATan2(0-YVel( "Arrow" ), XVel( "Arrow" ))

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    KLiK-iT's Avatar
    Join Date
    Sep 2011
    Location
    New Jersey
    Posts
    2,852
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by edman3d View Post
    Okay I actually figured this out finally. What I did was experiment with the code and I found that this does exactly what I wanted:

    (ATan((0-yVelocity( "arrow" ))/xVelocity( "arrow" ))+360)

    Posted the solution in case anyone else was wondering. Super smooth arrows now, yay.
    Would you mind posting a stripped down mfa example of this please.

  7. #7
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,341
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    See the "360░ Shooting" example here: http://www.sketchy.co.nf
    The frame entitled "Gravity & Destructible Terrain" includes this feature, using ATan2 (again, edman3d's expression will not work).

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    KLiK-iT's Avatar
    Join Date
    Sep 2011
    Location
    New Jersey
    Posts
    2,852
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    MuddyMole, thank you and you have nice examples on your site! Thanks again.

Similar Threads

  1. Making objects turn/rotate
    By PePeButte in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 31st May 2013, 08:58 PM
  2. HELP!! MAKING OBJECT'S SPEED FASTER WITH TIME
    By Mostafa in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 23rd May 2013, 07:21 PM
  3. making a turn based game
    By dray in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 13th January 2009, 11:03 PM
  4. X Speed Based on Distance
    By Strider in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 6th January 2008, 01:31 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
  •