How do I get the distance between 2 objects?

0 favourites
  • 5 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • How do I get the distance between right side of first object and left side of second object? This will be usefull to I make this:

    Thanks in advance!

  • distance(First_Sprite.BBoxRight, First_Sprite.Y, Second_Sprite.BBoxLeft, Second_Sprite.Y)

    But i think you are overcomplicating this a bit

  • distance(user1.x , user1.y , user2.x , user2.y)

    if character not mirrored distance(user1.x , user1.y , user2.x , user2.y)less then 200 trigger follow ( move towards angle 2 pixel)

    if character mirrored distance(user1.x , user1.y , user2.x , user2.y)less or equal 200 trigger follow ( move towards angle 2 pixel)

    repeat the code for both of them depends if you want them to follow each other or not!

    if user1.x = user2.x or user2.x-20 move forward towards user2.x +200 then trigger follow again ! to pass through and then come back is a bit tricky, the whole process

    the thing is you can also use LineOfsight that does basically the same thing what i said above! as Shadowdawnz said! but then you will need a trigger event or switch like when they face each other to be turned on but move forward then if distance is bigger or out of sight start following each other the thing is the whole process will make both characters wabble around each other at some point !

    how ever line of sight is a bit buggy and may not work all the time, my fish game template even though i could use line of sight, i dident was creating this weird comparisons and then wouldn't attack my hero fish! so i used the normal distance (x1,y1,x2,y2)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • , sorry, but I can't understand this code. How this will work in my .capx?

  • If i understood your post correctly Daniel, you could try using the Line of Sight behavior.

    If the follower is in the FOV of the player, then player can interact with follower. Maybe have the follower with Line of Sight as well, so if both the player and the follower are in each others FOV, then they are able to interact with each other.

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