Physics and Nodepool

Hello everybody,

I submitted a post about a month ago concerning using Coco’s built-in stats and Chrome’s dev tools. Within the post, I mentioned occasional frame drops my game experienced. In the end, I noticed the game jerked whenever the physics time jerked as well.

I changed the physics engine from bullet to built-in. While this lessened the amount
of frame drops, it still happens, especially on mobile.

My game is an endless runner that uses prefabs to generate the world in front of the player. Because of this, I use the Nodepool module to place the prefab levels onto the game world as well as recycle them when they are not in use.

Does the Nodepool module affect physics performance? Whenever an object is recycled to a Nodepool, does it get ignored from all physics operations? What causes the physics performance time to suddenly jump?

Thanks in advance. Any feedback will be appreciated.

Does the Nodepool module affect physics performance?

  • Nodepool does not affect physical performance.

Whenever an object is recycled to a Nodepool, does it get ignored from all physics operations?

  • When the node is recycled to the node pool, you can destroy the physically related components on the node and add new physically related components the next time you get the node from the node pool.

What causes the physics performance time to suddenly jump?

  • When you use a lot of physics components in the game scene, and produce physics effects, it will be very performance intensive, and the physics performance time will be relatively high at this time

Hello, thanks for the response.

I thought about disabling the box collider components whenever you recycle nodes, but I wasn’t sure whether this would do anything. Thanks for clarifying this.

While the built-in physics system does help performance, there is no way to add in mesh colliders to nodes. Because of this, I need to include multiple box colliders for each node to have an accurate fit. Perhaps this is what is bogging down the performance as well as the amount of nodes on the level.

Is there a way to enable colliders for nodes close to the player as well as disable colliders for nodes that are far away?

Thanks again for the clarification.

In this case, you need to do your own distance judgment on the distance between the nodes of the mounted physical components and the role nodes, and you cannot avoid the operation of using walk to traverse the node tree.

Hello
Once I made a endless runner game too but not in cocos.

I think when u recycled the node u can disable that node.

In my nodePool, i alwasy open node when i wanted to use it, otherwise keep it disable.

About your physics performans maybe ur two collision alwasy colliding.
If this is the case, you may experience performance loss.

Hello everyone.

Thanks for all the responses. I’ll keep this in mind.