Bug with gravityScale

Hi all,

I just noticed a bug, if I set gravityScale for an object before add it into physics engine, the engine will ignore the value *EVEN* gravityScale for the object is set again *AFTER* the addBody function call. Had anyone noticed that ?

The code is like this:

obj.gravityScale = 0

phyics.addBody( obj, … )

– the object responses to gravity

obj.gravityScale = 0

– the object still response to gravity

You can’t set gravity scale before adding the body and doing so (or setting other body parameters) will result in undefined results.

Tip: You can file a bug report if you want, but I don’t think it will get much priority.  I raised the same/related issue a couple years ago, but since it was technically incorrect usage the issue didn’t go anywhere.

PS - When I first noticed this I was puzzled and also thought it was really weird.  It took a while to track down since the code that was ‘pre-setting’ the values was buried.  Good job on working this out.

This isn’t a bug. Certain things must be done in order of process, especially with physics. Until an object is actually “made physical,” any properties you apply to it (for physics) will be treated as normal Lua properties, and they won’t “reverse apply” once you make the body into a physics object.

Best regards,

Brent

You can’t set gravity scale before adding the body and doing so (or setting other body parameters) will result in undefined results.

Tip: You can file a bug report if you want, but I don’t think it will get much priority.  I raised the same/related issue a couple years ago, but since it was technically incorrect usage the issue didn’t go anywhere.

PS - When I first noticed this I was puzzled and also thought it was really weird.  It took a while to track down since the code that was ‘pre-setting’ the values was buried.  Good job on working this out.

This isn’t a bug. Certain things must be done in order of process, especially with physics. Until an object is actually “made physical,” any properties you apply to it (for physics) will be treated as normal Lua properties, and they won’t “reverse apply” once you make the body into a physics object.

Best regards,

Brent