User Tag List

Results 1 to 9 of 9

Thread: Move an active object towards another using math.

  1. #1
    No Products Registered

    Join Date
    Dec 2006
    Posts
    319
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Move an active object towards another using math.

    A basic custom movement where, while a button is pressed, object A moves towards object B - with no extentions used.

    What kind of math is neseccary? Do I need to use the slope formula ((Ax-Ay)/(Bx-By)) anywhere? I don't care about changing the angle of the graphic, I am only interested in the specific math involved in moving the object towards another point. Could anyone point me to the right direction?

  2. #2
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: Move an active object towards another using math.

    You have two options - you can either move it based on how long you want it to take, or you can move it like a bullet and use speed instead of time.

    For the bullet method you'd need some basic trigonometry, but the other method is just division and multiplication.

    I'll make an example of both...
    Working as fast as I can on Fusion 3

  3. #3
    Clicker Multimedia Fusion 2 Developer
    Jax's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Move an active object towards another using math.

    So you are trying to find the equation of the line between two points. Let us say they are (a,b) and (A,B).

    So a straight line has the same gradient everywhere. So of course, the gradient is:

    G = (B-b)/(A-a)

    So a general point on the line will be in the form y = C + Gx, where C is to be determined. So to find it lets just use the first point we have:

    b = C + a G

    so C = b - a G

    and thus the line is the set of points y = C + xG. To keep the line in between them, you want x to range between a and A.

    Try this example:

    View MFA

    [Note how I take 100 points irrespective of the distance, which is probably not what you want. Also, check out how I use t, 0 < t < 1, instead of x for the parameterisation. I can then set x = a + (A-a)t]

  4. #4
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: Move an active object towards another using math.

    I think he wanted movement, not drawing.
    Here's my two cents examples: http://mfa.aquadasoft.com/view/1293057335-PointA_to_PointB

    Also, pressing Escape in your example doesn't seem to work...
    Working as fast as I can on Fusion 3

  5. #5
    No Products Registered

    Join Date
    Dec 2006
    Posts
    319
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Move an active object towards another using math.

    Thank you both, your responses were really fast! I have downloaded your files and study them. They are very useful, I don't know if I could do this without them.

  6. #6
    No Products Registered

    Join Date
    Aug 2010
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Move an active object towards another using math.

    This is very similar to my earlier question - "move, not reposition" with your second object replacing my mouse click.
    Here is the math I used:
    X = x1+(t(x2-x1))
    Y = y1+(t(y2-y1))

    and my example:
    http://www.buddhamind.info/mmf/AK_point-point.mfa

    Great to be able to study your examples LB - especially B. Thanks

    Great demo Jax. No use right now but I will tuck it away :]

  7. #7
    Clicker Multimedia Fusion 2 Developer
    Jax's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Move an active object towards another using math.

    LB, yes, the escape thing doesn't work, but that isn't important. I just used the action which sounded like it would work, but turns out it didn't and I didn't bother testing. I don't really use MMF so I didn't really know which actions work.

    But movements and drawing are the same thing, but with drawing it is more clear that it is really working, so I went with drawing. The important thing is understanding why it works anyway - then you can easily do whatever you like.

  8. #8
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: Move an active object towards another using math.

    Well, yours doesn't like undefined slopes.
    Working as fast as I can on Fusion 3

  9. #9
    Clicker Multimedia Fusion 2 Developer
    Jax's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Move an active object towards another using math.

    Haha yes good point.

Similar Threads

  1. Always - move object Y-1 is to slow, and always - move object Y-2 is to fast. help
    By Outcast in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 9th February 2012, 12:56 PM
  2. Transforming a polygon/active using math
    By ELCGames in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 10th April 2011, 07:38 PM
  3. active object to move slower than 1pixel per frame
    By ionside in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 21st January 2009, 08:05 PM
  4. active object move ?
    By ezra in forum File Archive
    Replies: 7
    Last Post: 5th April 2007, 12:40 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
  •