myBody.bounce

Is it possible to set the bounce value of a physics body after it’s initial creation? I thought:

[lua]myBody.bounce = 0.5[/lua]

would work, but it has no effect. It’d be great to manipulate the friction value, too…
Matt. [import]uid: 8271 topic_id: 3410 reply_id: 303410[/import]

Just a nudge; does anyone have any idea on this?

Thanks,

Matt. [import]uid: 8271 topic_id: 3410 reply_id: 10490[/import]

Do you mean you’d like to modify this value (or both “bounce” and “friction”) during gameplay? Meaning you’d like to modify them on the fly, perhaps changing a ball from being bouncy to non-bouncy?

Obviously you can declare such values when you create the physics body, but at this point, I don’t think there’s a way to modify physics properties after their creation. I believe Ansca has this feature on the roadmap and I expect it’ll be coming sooner than later.

Brent
[import]uid: 9747 topic_id: 3410 reply_id: 10508[/import]

Actually, you could try to remove the physics body (using body:removeSelf() ), then instantly replace it with another physics body containing different physical properties.

However, I’m not sure this will work. I have experienced some odd crashes when I try to manipulate physical objects on the fly. In general, I don’t think Corona likes when physics bodies are “forced” in certain ways upon a collision handler. For example, I have tried to snap a physics body to a particular X and Y position when it collides with something, and Corona crashes… however, building a “transition:to()” (even with a very fast 50 milliseconds) to move the body to that X/Y position works just fine. I think this is a bug and should be resolved soon… [import]uid: 9747 topic_id: 3410 reply_id: 10510[/import]

Ok, thanks for the input. I’m really hoping for variable values of friction, bounce and density - it would make for some interesting possibilities in games, I think.

Matt. [import]uid: 8271 topic_id: 3410 reply_id: 10530[/import]