How do I improve hit detection?

Get help using Construct 2

Post » Mon Dec 09, 2013 8:52 pm

I copied the Fruit Ninja code from the FAQ. And it works most of the time, but if I move the mouse too fast then the hits do not register. I've tried increasing the hit box and switching from "Touch" to "Mouse", but neither one worked.

Has anyone solved this issue?

https://dl.dropboxusercontent.com/u/19981154/TouchDemo.capx




Thanks!
KKiratTheKop2013-12-10 02:05:45
B
11
S
2
Posts: 68
Reputation: 982

Post » Mon Dec 09, 2013 11:34 pm

Simpler cap file.

https://dl.dropboxusercontent.com/u/19981154/TouchDemo.capx

Hitting the barrels causes an explosion. But if you move the mouse too fast then nothing happens.KiratTheKop2013-12-10 02:05:32
B
11
S
2
Posts: 68
Reputation: 982

Post » Tue Dec 10, 2013 1:44 am

.caproj requires dependent files and folders, it won't work.



You should upload a .capx instead of .caproj
B
97
S
35
G
29
Posts: 3,139
Reputation: 28,371

Post » Tue Dec 10, 2013 2:05 am

Thank you for pointing that out.

https://dl.dropboxusercontent.com/u/19981154/TouchDemo.capx
B
11
S
2
Posts: 68
Reputation: 982

Post » Tue Dec 10, 2013 3:35 am

A fast swipe can pass over a barrel's collision polygon in between ticks. The Slash object attempts to compensates by making it's width equal to the distance between last tick's touch position, and it's current tick's position. By having the barrels blow up when they collide with the slash object instead of the touch position, you'd probably get your desired result.zatyka2013-12-10 03:38:59
B
63
S
19
G
8
Posts: 341
Reputation: 12,130

Post » Tue Dec 10, 2013 6:43 am

Thanks for the explanation.

The barrels now are destroyed when they overlap with a slash. Unfortunately, when the barrels move, they can run into a fading slash and still be destroyed. Making the slashes fade faster solves this. But then the animation looks bad. So here is my work around:

1. Leave the slash object and behavior as is.
2. Create an identical slash object but make it invisible and have a very small fading time.

This does work but does anyone have a more compact solution?
B
11
S
2
Posts: 68
Reputation: 982

Post » Tue Dec 10, 2013 9:08 am

You're only going by the touch points, try changing the condition
"Touch: Is touching barrel" to "slash: Is overlapping barrel"

Also widen the collision polygon on the barrel a little at the base or nicking the corner could miss it.
B
24
S
9
G
3
Posts: 34
Reputation: 4,799


Return to How do I....?

Who is online

Users browsing this forum: Lordshiva1948 and 56 guests