Distance between objects

0 favourites
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • Hi guys and gals,

    How do I keep a distance between 2 objects?

  • I'm not sure if this is the "best" way to do it, but I used the following:

    System - Every tick ---> ObjectA SetPosition(ObjectB.X, ObjectB.Y)

    Hope that makes sense... Basically this will keep setting the position of ObjectA to that of ObjectB. You can add some pixels to the X or Y axis if you like.

  • you can determin the distance useing the command "distance (x1,y1,x2,y2)" and the react according to the result

  • Cheers peps!

    Ill give them booth ago!

    Rasmus: That's seems simple enough!

    Weishaupt: Where is this command "distance (x1,y1,x2,y2)"?

  • this is somehting you have to "type" to see it. Create an event -> System -> Compare two variables -> and type "distance" in the first data field...you should see a buble showing the exact syntax

  • Ah right I see it!

    So then all you do is set the distance (x,y) between the two objects.

    How does it new the position of each object without the object name?

  • no behaviour needed....

    <img src="http://quak.laurig.de/distance.PNG" border="0" />

  • Can't seem to get it to work, I must be doing something wrong!

    I have these 3 images and I want them to keep distance from each other, how do I achieve this?

    capx file would be nice, so I can see exactly what's happening in the events.

  • Pal - I dont have a CAPX wich I could send you. I just opend c2 to shoot that picture, but if you post your capx and let me know what you are trying to do, i could edit your file

  • Here is the file:

    capx     

    Its all touched based at the moment as I'm creating it for tablets and mobile phones.

    I have these 3 stickmen which have been sliced into individual parts (Head, Body and Legs). The parts are triggered to move when touch is activated, there are 3 hit areas behind each of the body parts (Head, Body & Legs).

    I have a 4th hit area which I want each body part to snap to if it comes into collision/overlaps with hit area 4, the problem is when I do this, all the body parts come together, I want them to keep safe distance between each other like there are when you load the capx.

    Hope that makes sense...

  • Use the pin behavior to pin your bodyparts together.

    If you need an example capx you have one in your c2 install\examples folder.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • ok...i have a hard time to understand what it shoud do hence I can not test on a touch device...and rewriting is something I don't like to do.

    You could assign a physics behaviour to all body objects and then use the "create distance joint" command to bind the parts together....or try "pinning" the parts together...

    is it correct, that "mdist" is supposed to be the distance between "touch" and "touched" bodypart?

    ninja'd... <img src="smileys/smiley18.gif" border="0" align="middle" />

  • Yes that is correct, its a bit of a bother being touch functions only!

    Kyatric, can you unpin aswell so for example: I touch and move object to hit area and it pins to hit area but if I touch and move object again it unpins itself and can move freely again?

  • The create distance joint works perfectly!

    Cheers lads!

  • Cheers lads!

    Are you from down under?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)