How do I disable collisions on offscreen sprites

Get help using Construct 2

Post » Tue Dec 29, 2015 10:50 pm

So, I have 2 sprites with lot of instances on layout (total of 120) and all of them are solids with collision enabled. Since this uses a lot of CPU to check collisions, I was wondering is there a way to disable collisions on instances that are off screen. I've tried something like "Sprite is (not)on screen -> collision disabled" but this diables collisions on all instances, both on screen and off screen.

Any ideas?
Image
B
7
S
1
Posts: 70
Reputation: 843

Post » Wed Dec 30, 2015 2:30 am

You could always hack it.. make an invisible sprite the size of the screen (make it follow camera if scene is large) and use Is-overlapping sprite to condition out ones that are off-scene.. there are more legit ways to do this but I like hacks. :)
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
60
S
15
G
8
Posts: 620
Reputation: 8,972

Post » Wed Dec 30, 2015 9:29 pm

hmmmm, interesitng will try it and see the impact on performance... Tnx!
Image
B
7
S
1
Posts: 70
Reputation: 843

Post » Thu Dec 31, 2015 9:53 am

saf wrote:So, I have 2 sprites with lot of instances on layout (total of 120) and all of them are solids with collision enabled. Since this uses a lot of CPU to check collisions, I was wondering is there a way to disable collisions on instances that are off screen. I've tried something like "Sprite is (not)on screen -> collision disabled" but this diables collisions on all instances, both on screen and off screen.

Any ideas?


" Sprite is (not) on screen -> collision disabled " should have worked! and it only includes sprites not on screen.. There might be some events that conflicts with it or maybe you did not include this event below.

If Sprite is on screen then
--> Set collision enabled
Image



The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
54
S
17
G
90
Posts: 1,111
Reputation: 59,120

Post » Thu Dec 31, 2015 11:32 am

Why set the collisions disabled?
The way you explain it the collisions happen because of the solid behaviour..
If that is true, setting the solid behaviour disabled should do the trck..
Also, if they are moving (without movement no collisions) you could just set the movement to true only when near enough..
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 » Thu Dec 31, 2015 4:43 pm

hmmm, idea behind it to reduce amunt of colision checks, the sprites are stationary but there is another sprite that has bullet behaviour and is all over the layout :)

Havent tried disableing solid behaviour, will try that...
Image
B
7
S
1
Posts: 70
Reputation: 843


Return to How do I....?

Who is online

Users browsing this forum: Ajbael, krombanna and 8 guests