How do I get more accurate collisions at high velocity?

Get help using Construct 2

Post » Wed Jun 04, 2014 10:13 pm

I was messing around with a "realistic" bullet penetration prototype and currently the detection of the collisions is less than desirable. Currently it completely bypasses any object smaller than the green box and will sometimes even skip it at its current size.

It runs fine locally at mostly 60fps, but this is just a messy prototype so don't expect the best performance. Firing too fast seems to wreck the fps in some cases also sounds might repeat or not play etc etc.

I have tried altering the stepping of the physics object, but this seems to have no effect.

I saw a posted example of pixel perfect collision detection, but unfortunately the performance was lackluster and used a messy loop that caused the cpu to hit 100% after 50+ shots.

Not looking for a concrete example, but anyone that can point me in the right direction would be much appreciated.

Trying not to get too heavily into the math side of things, but I'm thinking custom movement and some trajectory equations might have to happen.

Test:
WASD = Move gun around
R = reload
X = clear all lines/magazines
Left click = fire
B= Enable blood
https://dl.dropboxusercontent.com/u/14181859/bullet%20Test/index.html

EDIT: Updated the example to adjust velocity and fixed it so no matter what angle you shoot it should go out the right side.
Green = less than 50% the original speed
Yellow = between 90-51% original speed

Reload your cache or load it in a incognito tab to see changes.

Still can't get the collision to work right on thin objects, but I am working on another prototype using custom movement and some trajectory formulas.
Got it to be a little more accurate but not much.
B
6
S
1
Posts: 16
Reputation: 432

Post » Thu Jun 05, 2014 2:02 am

If you are using the bullet behavior, there isn't much you can do. If you are using the physics behavior, perhaps setting the "bullet" property on the bullet sprite might improve things out. Although a quick test I did with the bullet sprite set to fired with an impulse of 1000, worked perfectly, without even having to set the bullet property to "yes". In fact I don't think that the physics behavior allow for that kind of high velocities. 1000 impulse has the same speed as 10000 or 100000000....

Oh well... ;)
composer - multimedia artist
www.eli0s.com/en/
B
69
S
26
G
5
Posts: 1,146
Reputation: 9,829

Post » Thu Jun 05, 2014 2:49 am

eli0s wrote:If you are using the bullet behavior, there isn't much you can do. If you are using the physics behavior, perhaps setting the "bullet" property on the bullet sprite might improve things out. Although a quick test I did with the bullet sprite set to fired with an impulse of 1000, worked perfectly, without even having to set the bullet property to "yes". In fact I don't think that the physics behavior allow for that kind of high velocities. 1000 impulse has the same speed as 10000 or 100000000....

Oh well... ;)


I have the physics property set to bullet and it still fails to register hits that fall out of the "step" range and increasing the stepping does nothing.

What is odd is I am only applying an impulse of 0.6......

I think I might just write a custom behavior to do a trajectory/ delayed hitscan and do away with the bullet all together.
B
6
S
1
Posts: 16
Reputation: 432

Post » Thu Jun 05, 2014 3:19 am

Well look at the math. If an object is going faster than 60 pixels per second, and your solids are smaller than 60 pixels, then there's a high probability it can skip the object.
You're just not going to get pixel perfect collisions in a javascript engine running v synced at 60 fps.... with crappy garbage collection.
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

Post » Thu Jun 05, 2014 4:45 am

newt wrote:Well look at the math. If an object is going faster than 60 pixels per second, and your solids are smaller than 60 pixels, then there's a high probability it can skip the object.
You're just not going to get pixel perfect collisions in a javascript engine running v synced at 60 fps.... with crappy garbage collection.


Makes sense. I guess I could try doing an invisible cage object that is much larger and then offset the impact point.
B
6
S
1
Posts: 16
Reputation: 432

Post » Thu Jun 05, 2014 11:56 am

Well, physics collisions are accurate. The problem is with the normal collision/overlaping check. What would be nice is to have physics objects as detectors/triggers. That way we would have accurate detections either upon collisions, or while overlaps.

I am not sure what is the purpose in your gameplay, if you are trying to simulate penetration damage. I did some checks and came up with a basic capx that does detect all collisions, perhaps it will be of some use to you. Perhaps not. Here it is never the less ;)
You do not have the required permissions to view the files attached to this post.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
26
G
5
Posts: 1,146
Reputation: 9,829

Post » Thu Jun 05, 2014 4:45 pm

Well then, why don't you check the distance between the objects and the bullet, if its smaller than the distance traveled by the bullet in a tick, then you could move the bullet by that distance in the angle of the bullet and check for collisions or use an invisible object to do the checking, if that object collides with the target then the bullet has hit it
B
42
S
17
G
17
Posts: 2,247
Reputation: 17,461

Post » Thu Jun 05, 2014 8:38 pm

eli0s wrote:Well, physics collisions are accurate. The problem is with the normal collision/overlaping check. What would be nice is to have physics objects as detectors/triggers. That way we would have accurate detections either upon collisions, or while overlaps.

I am not sure what is the purpose in your gameplay, if you are trying to simulate penetration damage. I did some checks and came up with a basic capx that does detect all collisions, perhaps it will be of some use to you. Perhaps not. Here it is never the less ;)


Thanks for the example, but this is similar to what I was already doing. The problem is if you increase the impulse or make the board any thinner it will start to miss collisions.

I ended up settling for an invisible cage around small objects that is much larger than the object itself, and then getting the distance and moving the impact point to the object. It works fine for what I wanted to do.

There isn't really any gameplay purpose, just a prototype for ballistic behaviour that I wanted to mess around with. I'm going to put it aside for now and revisit it later after some other ideas.
B
6
S
1
Posts: 16
Reputation: 432


Return to How do I....?

Who is online

Users browsing this forum: David181, evillair and 62 guests