User Tag List

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

Thread: How do you stick one object to another at position and direction?

  1. #1
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do you stick one object to another at position and direction?

    Almost like a drag and drop, but not with a mouse, I'm trying to make it so that when one Active Object overlaps a second Active Object, the second Active Object sticks to the first at the coordinates they overlap, and also stay at that relative positioning depending on which way the first Active Object rotates. A bit like a manual "Set Position" action but with varied X and Y values.

    And... I haven't been able to figure it out. Have been messing with Sin and Cosine and distances a bit but it's still not working right.

    StuckRotation.mfa

  2. #2
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleMac Export Module
    dsilvers's Avatar
    Join Date
    Jun 2008
    Location
    Boston, MA
    Posts
    665
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    On collision, trigger a flag and store the arc tangent of the distance between the two objects as an alterable value: ATan2(object A's Xpos - object B's Xpos, object B's Ypos - object A's Ypos). This will create the angle you can use in your Sine and Cosine calls, so set Object B's X position to Object A's X position + Sin (Arc Value), and Set Object B's Y position to Object Y's Y position - Cos (Arc Value).

  3. #3
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do you stick one object to another at position and direction?

    Thanks! But, thaaat... didn't work at all. D:

    Attachment 16878

  4. #4
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I was working on the first time seemed like it wanted to work, but I have a feeling I got something backwards.

  5. #5
    No Products Registered

    Join Date
    Jan 2014
    Location
    Indiana, USA
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Kid R, I might have had a similar question that got answered. Check out my thread:

    http://community.clickteam.com/threads/92768-rotation-and-fixed-point-movement-help

  6. #6
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That looks neat. I can tell that it's similar to what I'm trying to figure out though. Basically in my first example, I want it so that when you press "Z," the object that changes color doesn't move and becomes fixed to that spot on the larger object no matter where said larger object is placed in the future or which way it rotates.

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Hello Kid_Roleplay,

    I still can't clearly figure out what you're needing,
    you would like to "fix" the green diamond active into the "blue square" object at any given position,
    and keep it so that if you rotate the blue object, green diamond keeps remaining in its correct fixed position?

  8. #8
    No Products Registered

    Join Date
    Jan 2014
    Location
    Indiana, USA
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, the concept is the same and should be adaptable. Are you trying to account for like being hit by an arrow (projectile), being held on to by an enemy, or picking up a weapon?

    I think it's fairly easy until you want to move between frames. You would need to capture the attach points and save them for future use. Actually, you'll have to capture the points of contact anyway so you can always have the object affixed to the player. I *think* an issue you might be grappling with is how to attach single instances of like objects to the player. When the object collides or overlaps the player:

    1) capture the fixed ID of the object that is colliding. I don't think this step is absolutely necessary but it might come in handy so you can specifically deal with the individual objects when needed.
    2) capture the coordinates of impact relative to the player, store with the object
    3) turn on a flag on the object
    2) in a separate event, based on the flag, change the animation or color of the object to reflect what you want it to look like. This will take care of every like object in the future.
    3) Now the fun part, I think you need a for each loop on each object...someone can correct me. For each object that has a flag active, 'attach' to the player at the stored points at the current angle. The attach code is what keeps keeps it in place and referenced as the player angle changes.

    I would start there. I don't know if I'm good enough to program this out myself in short order (I have my own issues to deal with) but I think the above is what you want. Start simple, like just see if you can get the object to collide and change its animation. Than try to affix it to the player.

  9. #9
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by schrodinger View Post
    Hello Kid_Roleplay,

    I still can't clearly figure out what you're needing,
    you would like to "fix" the green diamond active into the "blue square" object at any given position,
    and keep it so that if you rotate the blue object, green diamond keeps remaining in its correct fixed position?
    Yup. That's correct. And no matter which direction the "blue square" object is already facing. My ... attempt... to try to get that to work is in the first attachment.

  10. #10
    Clicker Fusion 2.5

    Join Date
    Sep 2006
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To Jarred: I'm looking for the Math or MMF2 equivalent of doing a "Set position of Object B to (X, Y) from Object A's location and direction," but through expressions such to allow the use of variables.

    As if you were to cut out a rectangular piece of duct tape and held it flat, then pressed its sticky side down onto a paperclip. The paperclip will be stuck to that spot no matter which way the duct tape was originally facing, and will move and rotate with the duct tape until it is pulled off again.

    Fixed values and the like I'm not worried over at the moment and know how to do. It's just this no-good, evil math stuff that's making me pout.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. help... Stick to a rotating object
    By Tuna in forum Fusion 2.5
    Replies: 5
    Last Post: 27th November 2014, 08:50 PM
  2. [OUYA HELP]Set Active position by Right Stick
    By paobrasil in forum Android Export Module 2.5
    Replies: 1
    Last Post: 2nd June 2014, 10:07 PM
  3. Replies: 5
    Last Post: 1st March 2014, 12:31 PM
  4. Position the virtual stick
    By Nellatermica in forum Android Export Module Version 2.0
    Replies: 3
    Last Post: 12th May 2013, 08:38 PM
  5. Stick to object bug
    By Evilized79 in forum iOS Export Module Version 2.0
    Replies: 0
    Last Post: 1st February 2012, 05:31 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •