How do I check if an object is overlapping a circular area?

Get help using Construct 2

Post » Mon Apr 13, 2015 10:34 am

Hi,

I want to check if an object is overlapping a circular area around another object. How can I go about doing this? I tried using "is overlapping at offset" but I am getting inconsistent results. (Maybe I don't know the right equation?) I don't want to use an invisible sprite as I have multiple objects that need to be checked.
Basically if an object comes in a circular proximity of another object, I want to the first object to do something. Is using line of sight a way to do this?
Any help will be greatly appreciated.
B
5
Posts: 13
Reputation: 249

Post » Mon Apr 13, 2015 10:39 am

I guess you could use distance(object.x,object.y,object2.x,object2.y)
This would calculate the distance between imagepoint0 of object1 and imagepoint0 of object2
if this distance is less than 100, object2 would be within a circle of 100 px around the center of object1
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Apr 13, 2015 2:01 pm

Thank you! It was super simple. just never thought of it this way!
B
5
Posts: 13
Reputation: 249


Return to How do I....?

Who is online

Users browsing this forum: GoblinPortal, MAVERICK, mchulet, NN81, whitephon and 8 guests