User Tag List

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

Thread: Get direction and speed (Please help)

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    Captain_Harris's Avatar
    Join Date
    Aug 2011
    Posts
    336
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Get direction and speed (Please help)

    I have a player that move left and right. it is controlled by - always set x position to x mouse.

    1.how can i get the direction of the player.

    2. how can i get the speed of the player.

    ( i can not use the 8 direction movement, because i can not control it without buttons )

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    tompa's Avatar
    Join Date
    Nov 2011
    Location
    Uppsala, Sweden
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One solution is to measure distance between 2 points within a constant timeframe.

    When these points exist in a system, it's viable to calculate speed (from distance in time) and angle.

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    Captain_Harris's Avatar
    Join Date
    Aug 2011
    Posts
    336
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Get direction and speed (Please help)

    Can you give a example please.

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    tompa's Avatar
    Join Date
    Nov 2011
    Location
    Uppsala, Sweden
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, this widget uses a constant timeframe.


    A similar solution is to save Xmouse & Ymouse in variables every 3ms

    Velocity example (Euclidean)
    A = Mouse position 3ms ago
    B = Mouse position now
    E = Velocity


    E = sqr(((A.x - B.x) pow 2) + ((A.y - B.y) pow 2))


    Angle between 2 points
    A = Mouse position 3ms ago
    B = Mouse position now
    C = Angle


    C = ATan2(A.y - B.y, B.x - A.x)




    ...I know, I post these formulas often.

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    Captain_Harris's Avatar
    Join Date
    Aug 2011
    Posts
    336
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do not know if my intelligence is sufficient for. but i'll try to work with this. Thank you.
    if anyone knows an easier way, please help.

    one thing. how can i get xmouse 3ms ago ?

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    tompa's Avatar
    Join Date
    Nov 2011
    Location
    Uppsala, Sweden
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's a clock inside conditions.

    It's enabling conditions to run "every" x time.
    Attached files Attached files

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    Captain_Harris's Avatar
    Join Date
    Aug 2011
    Posts
    336
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    Decoamorim's Avatar
    Join Date
    May 2013
    Location
    Florianópolis, Brazil
    Posts
    238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tompa,

    Do i have to use this expression on a value?

    For an exemple, i want to a motion set of events happens when the object X is at 50 pixels away from the object Y.

    So i used "COMPARE TO GENERAL VALUES" , like this:


    Sqr(X( "Fidao xbox" )-X( "enemy" ))*(X( "Fidao xbox" )-X( "enemy" ))+(Y( "Fidao xbox" )-Y( "enemy" ))*(Y( "Fidao xbox" )-Y( "enemy" ))

    greater or equal

    50

    Than told the object enemy to walk left. But did not work.
    Only works when i said that the expression is different from ZERO.

    Why is that? What am i doing wrong here?

    I want to (exemple) at 50 pixels the enemy walks to the object, than when its close, lower than 50, starts a random atack that i created.

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AyreGuitar's Avatar
    Join Date
    Jan 2011
    Location
    Wales, UK
    Posts
    1,113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Decoamorim - Compare to general values won't work on multiple objects (eg your enemy objects). Instead, try setting an Alt Val in the enemy objects to your calculation eg:

    Always:
    Alt Val A("enemy")=Sqr(X( "Fidao xbox" )-X( "enemy" ))*(X( "Fidao xbox" )-X( "enemy" ))+(Y( "Fidao xbox" )-Y( "enemy" ))*(Y( "Fidao xbox" )-Y( "enemy" ))

    If Alt A("enemy")>=50
    (Do your actions here)

    Hope that helps!

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    tompa's Avatar
    Join Date
    Nov 2011
    Location
    Uppsala, Sweden
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I looked at your function decoa. Your parentheses are just placed wrong. Square root should apply over the whole Euclidean formula.
    If the formula looks messy you can use pow2 instead of multiplying terms. In MMF2 Developer the pow2 = ^2.

    example
    (x + y) * (x + y) = (x + y) pow2


    added
    if you plan to have more than one entity (enemy) you should follow guitars instructions.

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, 02:49 PM
  2. Get Direction (Please Help)
    By Captain_Harris in forum iOS Specific Example Files
    Replies: 0
    Last Post: 13th May 2013, 02:30 PM
  3. Getting Speed in the X Direction from Clickteam Movement Controller
    By amaire13 in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 24th November 2012, 08:07 PM
  4. mouse n direction n speed or turning n what not
    By gordonquinton11 in forum The Games Factory 2 - Technical Support
    Replies: 5
    Last Post: 28th September 2011, 02:54 AM
  5. Set speed to speed -1 no longer works?
    By 00J in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 13th November 2007, 06:13 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
  •