Test if a single x/y position is overlapping a given hitbox?

Get help using Construct 2

Post » Sat Oct 25, 2014 11:26 am

hi.
I'd like to check if the center of a moving object (default imagePoint) is currently colliding or overlapping the hitbox of another object. How can I achieve this ?
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Sat Oct 25, 2014 12:00 pm

Although I'm probably just to tired to think of an easier solution:
Would it be possible to use the bounding box of the hitbox-object?

If so you could check if object.imagepointx(0) (the x coordinate of the default imagepoint) is greater than the hitbox.bboxleft and smaller than hitbox.bboxright and the same for the object.imagepointy(0) with bboxtop and bboxbottom..
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 » Sat Oct 25, 2014 2:46 pm

I thought about this but it would be a nice solution if my target hitbox was a square, which is not :)

edit : well, it's actually a circle. Maybe I can just, every tick, check the distance between the center of my first object and the center of my target. If the distance is equal or smaller than the target radius, then it's a hit.
Last edited by Coin-coin le Canapin on Sat Oct 25, 2014 4:35 pm, edited 1 time in total.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Sat Oct 25, 2014 3:37 pm

or you can pin some small sprite in the middle of the ball...
Image
B
64
S
23
G
7
Posts: 1,483
Reputation: 10,827

Post » Sat Oct 25, 2014 4:35 pm

I thought about this too, I'll give a try.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Sat Oct 25, 2014 5:56 pm

System: Pick overlapping point
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,630

Post » Mon Oct 27, 2014 11:16 pm

Nice, thanks ! :)
B
12
S
7
G
7
Posts: 450
Reputation: 4,276


Return to How do I....?

Who is online

Users browsing this forum: sublimate and 4 guests