User Tag List

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

Thread: move an object from it's location to mouse click x and y

  1. #1
    Clicker Fusion 2.5 DeveloperSWF Export Module
    WEich1213's Avatar
    Join Date
    Nov 2013
    Location
    Carlsbad, Ca. USA
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    move an object from it's location to mouse click x and y

    Hello, I'm trying to move an object from it's current location to where I click the mouse.
    I am using this equation to set direction:

    PlayerVX = Cos(3.141592654 * PlayerRotDegrees / 180 )
    PlayerVY = Sin(3.141592654 * PlayerRotDegrees / 180 )

    then to make it move I use this:

    ObjectX = ObjectX+PlayerX*PlayerSpeed
    ObjectY = ObjectY+PlayerY*PlayerSpeed

    I think the equations to set direction is wrong. I'm getting these equations from a Flash AS3 book, but don't think I'm doing it right.
    Anyone know how to do it?

  2. #2
    Clicker Fusion 2.5 DeveloperSWF Export Module
    WEich1213's Avatar
    Join Date
    Nov 2013
    Location
    Carlsbad, Ca. USA
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry to make it move I use this:
    ObjectX = ObjectX+PlayerVX*PlayerSpeed
    ObjectY = ObjectY+PlayerVY*PlayerSpeed

  3. #3
    Clicker Fusion 2.5 DeveloperSWF Export Module
    WEich1213's Avatar
    Join Date
    Nov 2013
    Location
    Carlsbad, Ca. USA
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I re read my post and I think both equations don't work for what I'm trying to do. I had been working a long time before I posted it so sorry it was wrong. Anyway, anyone know how to make a character walk from it's location to where you click the mouse?

  4. #4
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Pineapple's Avatar
    Join Date
    Oct 2010
    Posts
    431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The reason it's not working is that flash/C++/java,etc. use radians and Fusion uses angles.

    The vx/vy parts should be Sin(PlayerRotDegrees) and Cos(PlayerRotDegrees).

  5. #5
    Clicker Fusion 2.5 DeveloperSWF Export Module
    WEich1213's Avatar
    Join Date
    Nov 2013
    Location
    Carlsbad, Ca. USA
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so it should be:

    PlayerVX = Cos(PlayerRotDegrees)
    PlayerVY = Sin(PlayerRotDegrees)
    ?

    I tried it that way just now but it doesn't work to well
    PlayerRotDegrees is the Angle

  6. #6
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Pineapple's Avatar
    Join Date
    Oct 2010
    Posts
    431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, if you want to use trigonometric movement like in your example:

    On click: set "TargetX" to Xmouse, set "TargetY" to Ymouse, set "TargetAngle" to ATan2(TargetX - PlayerX, TargetY - PlayerY)+180
    Always: set "PlayerX" to PlayerX + PlayerSpeed * Sin(TargetAngle), set "PlayerY" to PlayerY + PlayerSpeed * Cos(TargetAngle)
    Always: set Player X coordinate to "PlayerX", set Player Y coordinate to "PlayerY"

  7. #7
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,699
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Hi. If you are referring to "point and click", I have examples on my website.

    Marv
    ​455 MMF2 & CTF 2.5 Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  8. #8
    Clicker Fusion 2.5 DeveloperSWF Export Module
    WEich1213's Avatar
    Join Date
    Nov 2013
    Location
    Carlsbad, Ca. USA
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks Marv, I downloaded the Point and Click example, but the player character doesn't go directly to the mouse click, the player kind of goes one direction and then another till he gets to the mouse click. Do you have any examples of the character going from his original point to the mouse click directly?

    Pineapple I couldn't get those equations to work, he goes all over the place, but thanks anyway.

    I was able to find the angle from the player to the mouse click with this equation I found on the forums:
    ( ATan2(MouseYForPlayer - Y( "Active 3" ), MouseXForPlayer - X( "Active 3" ) ) + 360 ) mod 360

    but I don't know how to get the player to walk along the angle to the mouseclick.

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    rubes's Avatar
    Join Date
    May 2011
    Posts
    364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's an example with not a lot of fancy math. Where you click is an X (you could hide this, but for demo purposes, it's visible) The system check's the player's x&y values against the X's x&y values, and modifies accordingly.
    Attached files Attached files

  10. #10
    Clicker Fusion 2.5 DeveloperSWF Export Module
    WEich1213's Avatar
    Join Date
    Nov 2013
    Location
    Carlsbad, Ca. USA
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried to open it but it's just an empty php file.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. How would you move an object in straight line pixel by pixel from location to another
    By Tsun in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 22nd December 2012, 10:38 PM
  2. Click the mouse and move character?
    By m00nbeam360 in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 19th July 2012, 05:11 PM
  3. [Request] On Mouse Move Object
    By Tim in forum Extension Development
    Replies: 8
    Last Post: 18th November 2009, 08:33 PM
  4. Move to mouse click with animation
    By Jo_Jo in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 26th October 2008, 02:57 AM
  5. Move object relative to mouse & click
    By Villy in forum File Archive
    Replies: 0
    Last Post: 8th November 2006, 09:26 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
  •