Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Physics off screen and modes

Author
Message
brunuu
2
Years of Service
User Offline
Joined: 4th Jun 2018
Location:
Posted: 11th Aug 2020 13:13
I need the physics of off-screen sprites to be static for performance reasons and when they enter the screen they change the mode to dynamic.
But these sprites have joints and using SetSpritePhysicsDelete to switch modes will remove those joints.
So what better way to do this?
gosukiwi
AGK Tool Maker
User Offline
Joined: 24th May 2020
Location: Argentina
Posted: 11th Aug 2020 22:40 Edited at: 11th Aug 2020 22:41
Are you actually running into performance issues?

I think Box2D already does many optimizations, not sure about this one in particular, though. The documentation on SetSpritePhysicsOn states:

Quote: "Once you have called this command to determine the mode of the sprite, further calls will ignore the mode values and it will only reactivate a sprite that has been turned off, as the mode cannot be changed whilst the sprite is in the physics system."


Maybe you could turn physics off/on manually when they are off-screen?
brunuu
2
Years of Service
User Offline
Joined: 4th Jun 2018
Location:
Posted: 11th Aug 2020 23:06
There are at least 10,000 active objects in a level, all with joints, it is quite intensive, the only way to solve this is as the player moves away is to disable the physics in those sprites and activate the sprites that are approaching.

Imagine hundreds of these types of buildings that are destructive over an entire level


You can't use SetSpritePhysicsOn because to change the mode you need to turn off the physics on this Sprite and with that the joint is lost

gosukiwi
AGK Tool Maker
User Offline
Joined: 24th May 2020
Location: Argentina
Posted: 12th Aug 2020 00:28
I see. I'm afraid I don't know much about the physics engine to help you with this. Maybe ask on Discord?

I'd worry about that when I have the actual performance hit though. Or are you having the issue now?
brunuu
2
Years of Service
User Offline
Joined: 4th Jun 2018
Location:
Posted: 12th Aug 2020 02:10
I'm already having it, but it was expected, it's normal

Login to post a reply

Server time is: 2020-10-25 16:29:57
Your offset time is: 2020-10-25 16:29:57