How do I get the distance between 2 objects?

Get help using Construct 2

Post » Fri Jun 19, 2015 11:48 pm

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:
Image
Thanks in advance! :D
Liked something I say?
Tip. My Bitcoin address: 1PLaeKmXQ8vEdGGJqXMq3KyB8hxeddxeSv
B
24
S
7
G
4
Posts: 326
Reputation: 3,878

Post » Sat Jun 20, 2015 12:20 am

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

But i think you are overcomplicating this a bit
ImageImageImageImage
B
157
S
66
G
41
Posts: 2,599
Reputation: 34,825

Post » Sat Jun 20, 2015 12:43 am

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

@DaniellMesquita
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)
Last edited by gamecorpstudio on Sat Jun 20, 2015 8:42 pm, edited 3 times in total.
B
75
S
22
G
68
Posts: 1,337
Reputation: 43,271

Post » Sat Jun 20, 2015 4:50 am

@gamecorpstudio, sorry, but I can't understand this code. How this will work in my .capx?
Liked something I say?
Tip. My Bitcoin address: 1PLaeKmXQ8vEdGGJqXMq3KyB8hxeddxeSv
B
24
S
7
G
4
Posts: 326
Reputation: 3,878

Post » Sat Jun 20, 2015 5:13 am

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.
B
21
S
5
Posts: 44
Reputation: 1,644


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 14 guests