[SUGGESTION]Physics: check if landed on ANY sprite

Discussion and feedback on Construct 2

Post » Sat Jul 28, 2012 1:35 am

Probably not the first one to request that, but here goes:

It would be very nice to have a feature for the physics behavior that simply checks if there's ANYTHING underneath the player. So we can know when the object hits the floor. Without having to do collision checks with every instance of a sprite. Check underneath through 10 pixels (user defined)... if you hit anything, it's true, if not, it's false.

Also, if physics could interact with a simple solid object... I wonder if it would make collision checks a bit faster or help the above at least?

Thanks
B
4
Posts: 41
Reputation: 407

Post » Sun Jul 29, 2012 11:56 am

I don't think you actually want this! "Anything" includes the background objects, so would likely be true all the time, making it useless.

Why not add all the objects you want to test for collision with to a family (perhaps name it "Floor")? Then you can test for overlap with any of the objects in the family with a single "Is overlapping floor" event. More information in the Families manual entry.Ashley2012-07-29 11:56:27
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,508

Post » Sun Jul 29, 2012 1:55 pm

I meant "anything" on the same layer, for instance... You know a brutal way to simplify and optimise collision checking on many objects.

Families! Thanks for the tip, Ashley.

Do families help the performance of a game for collision checking for instance?
If I have 50 sprites (5 types of sprites, 10 instances each) to do a coll check with a physics ball(player) if I put them all in the same family, will the engine do just one coll check for all at once?

Or is it purely to simplify the event sheet?TheDev2012-07-29 14:00:04
B
4
Posts: 41
Reputation: 407

Post » Sun Jul 29, 2012 1:57 pm

The engine first does a very rough check, which excludes any objects outside the maximum possible collision area. This is a very fast check. Then it checks objects within that area using more accurate criteria. You shouldn't have to worry about number of objects, as long as there aren't too many collision checks going on.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sun Jul 29, 2012 4:00 pm

Updated post above.

Thanks Mipey. Yes actually it seems like when you use a physics object all floor sprites need to have physics too so that means coll checking with them just to know if it's on a floor.

I made some tests and just having 10-15 floor sprites with physics dramatically reduces performances on slow devices like an ipod2.

So am I missing something? Does that mean this is the performance limit of javascript?
The most logic you can run on a slow device is a few lines of code and 5 collision checks?

I am surprised and dissapointed. :'(
TheDev2012-07-30 01:49:05
B
4
Posts: 41
Reputation: 407

Post » Mon Jul 30, 2012 1:50 am

Bump of the last hope!:-P
B
4
Posts: 41
Reputation: 407

Post » Mon Jul 30, 2012 1:52 am

If you are not using a wrapper... yes. Unfortunately, it's that bad.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Mon Jul 30, 2012 1:35 pm

Oh, but I am using Cocoon... that what you call a wrapper?

If so then I guess I'm sh*t out of luck having paid for a personal license and not being able to make a simple physics game for a lack of solution to my problem.
Looks like I was shooting a little too high for C2.

Thanks for your input anyways.TheDev2012-07-30 13:46:32
B
4
Posts: 41
Reputation: 407

Post » Mon Jul 30, 2012 1:54 pm

Mobile devices are generally too weak to support complex physics games. You should avoid using physics for mobile devices if possible.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,508

Post » Mon Jul 30, 2012 4:56 pm

High expectations on HTML5 specially on mobile currently will only disappoint you i fear, even with wrappers :(
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 4 guests