Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hello, I enabled physics simulation for my game then when I delete a node, I can still collide with it even when the node disappeared. I searched a little in the forum and saw a fix for this problem is to use ccbUpdatePhysicsGeometry( ). I would like to know if I do things correctly, I just have to execute javascript every seconds, and I just add the command: ccbUpdatePhysicsGeometry( ) ? I have to just paste this command and nothing else, or do I have to add something basic around it? thanks in advance. |
||||
|
You need to pass a command to update the physics geometry every time you move something when physics is enabled. |
||||
|
I use the command ccbUpdatePhysicsGeometry( ) in javascript. I did it on the scen root node , every 10ms ,execute the javascript command ccbUpdatePhysicsGeometry( ). It is the right way to do it? At least it does solve my problem but will it cause other problem? |
||||
|
Glad it's working! No, I don't recommend doing it every 10ms for 2 reasons... 1- If you have "many" call events like that, it "can" end up slowing your game down. 2- Using a short delay such as 10ms will use up more resources on slower processors. Don't be afraid of using "every few seconds" events, but It's best to do a single update immediately after the event whenever you can and save the every few seconds for things that need constant updates. If the game starts to crawl after a lot of development, you can increase the times from 10ms to 30, 50,70,100 etc and it may improve the run-speed of the game. Personally I use every few seconds extensively, I usually have many events running like this but while the games run on my machine, they tend to struggle and run slow on other machines - so I'm learning to use it less often when possible. If it works, it's fine - if you run into problems in the future, try adjusting it to single events instead of every few milli-seconds. |
||||
|
Thanks again VP, very usefull!! |
|