How can I print physics objects properties to terminal for debug purposes?

Hello

I am new to Corona and Lua in general and I am having some problems which I am sure I could fix if I could just print some data to the terminal for debug purposes.

I need to be able to print the physical properties which are set in the physics.addBody() function. For example I need to print the friction, bounce and density properties to the terminal.

My reason being that in my game when the player “dies” I restart the game using Storyboard etc, but at some point I believe these physics properties change/do not initialise, resulting in the character movement being completely different than it was in the first round.

I tried the code below but its just printing “nil” every time :frowning:

print(mainFloor.bounce)

print(mainFloor.friction)

print(mainFloor.density)

Any help would be appreciated :slight_smile:

Thanks guys

Try this.

local bodyProperties = { density=10.0, friction=1.0, bounce=1.0 } physics.addBody( mainFloor, bodyProperties ) for k, v in pairs(mainFloor) do print("mainFloor: ", k, v) end

This will list all items in bodyProperties

Good luck!

burhan

@Burhan J

 

That’s precisely what I have been looking for  :) Thank you 

Try this.

local bodyProperties = { density=10.0, friction=1.0, bounce=1.0 } physics.addBody( mainFloor, bodyProperties ) for k, v in pairs(mainFloor) do print("mainFloor: ", k, v) end

This will list all items in bodyProperties

Good luck!

burhan

@Burhan J

 

That’s precisely what I have been looking for  :) Thank you