I have a game where the player can edit certain physics properties when they pause the game. Right now, they can edit gravity and bounce. There is no problem editing gravity because it is not a property of the player object. The way my code is set up, whenever the pause overlay is called, the player is removed from the physics enviroment via physics:removeBody. Then, after the player is done editing settings, player:addBody is called with the new, updated settings. However, in the parent scene (or in the scene:show of the overlay, I’ve tried both) when I try to call player:removeBody, I get error bad argument #-2 to ‘removeBody’ (Proxy expected, got nil). I think it has something to do with trying to access the player in both scenes but I’m not sure. As a result of this problem (if I just remove physics:removeBody), then after the creation of the player you can’t edit bounce. If something was unclear (I get sidetracked easily) just let me know and I will modify the post. Any help would be greatly appreciated! Thanks in advance!
Actually I didn’t read your post because it was an illegible wall of text. so my initial response was a guess.
Please use sentences and paragraphs with nice line breaks between when posting. Walls of text are a super-put-off for folks like me who skim long posts.
Anyways, the problem is you’re doing it wrong.
Do this:
physics.removeBody( obj )
not
physics:removeBody( )
and not
obj:removeBody( )
Also, if you have already removed the display object, you don’t need to do anything to remove the body.
Wow, I feel dumb now. Thanks for your help! I will try to be better about formatting my text from now on.
Hey. Don’t feel dumb.
We all make the dot versus colon mistake early on, and in my case I still do either by typo or forgetfulness.
Also, it is natural to think, “call a method attached to the object”. I mean, that is what we do for ‘setLinearVelocity()’, etc. right?
-Ed
Actually I didn’t read your post because it was an illegible wall of text. so my initial response was a guess.
Please use sentences and paragraphs with nice line breaks between when posting. Walls of text are a super-put-off for folks like me who skim long posts.
Anyways, the problem is you’re doing it wrong.
Do this:
physics.removeBody( obj )
not
physics:removeBody( )
and not
obj:removeBody( )
Also, if you have already removed the display object, you don’t need to do anything to remove the body.
Wow, I feel dumb now. Thanks for your help! I will try to be better about formatting my text from now on.
Hey. Don’t feel dumb.
We all make the dot versus colon mistake early on, and in my case I still do either by typo or forgetfulness.
Also, it is natural to think, “call a method attached to the object”. I mean, that is what we do for ‘setLinearVelocity()’, etc. right?
-Ed