How to set body.type from DYNAMIC to STATIC on contact?

184 views
Skip to first unread message

Michael N

unread,
Mar 25, 2014, 8:52:56 AM3/25/14
to nape-p...@googlegroups.com
Hi,

I want to set a DYNAMIC body to STATIC when it hits another object. 

1. When I do it on CbEvent.BEGIN it will crash.

2. When I do it on CbEvent.END, it works sometimes. Sometimes it will crash, especially when the contact will be between two objects.

Where I have to change the body.type to STATIC when it hits another object the right way? Or is there a better solution?

Thank you!! :)



This it the crash-message I receive:
TypeError: Error #1009: Cannot access a property or method of a null object reference.

at zpp_nape
.space::ZPP_Space/presteparb()
at zpp_nape
.space::ZPP_Space/prestep()
at zpp_nape
.space::ZPP_Space/step()
at nape
.space::Space/step()
at citrus
.physics.nape::Nape/update()[C:\Users\Aymeric\Workspace\Flash\Libraries\Citrus-Engine\src\citrus\physics\nape\Nape.as:108]
at citrus
.core::MediatorState/update()[C:\Users\Aymeric\Workspace\Flash\Libraries\Citrus-Engine\src\citrus\core\MediatorState.as:81]
at citrus
.core.starling::StarlingState/update()[C:\Users\Aymeric\Workspace\Flash\Libraries\Citrus-Engine\src\citrus\core\starling\StarlingState.as:72]
at game
.levels::ALevel/update()[/game/levels/ALevel.as:501]
at game
.levels::ALevelGameplay/update()[/game/levels/ALevelGameplay.as:385]
at citrus
.core::CitrusEngine/handleEnterFrame()[C:\Users\Aymeric\Workspace\Flash\Libraries\Citrus-Engine\src\citrus\core\CitrusEngine.as:362]
at citrus
.core.starling::StarlingCitrusEngine/handleEnterFrame()[C:\Users\Aymeric\Workspace\Flash\Libraries\Citrus-Engine\src\citrus\core\starling\StarlingCitrusEngine.as:309]




Michael N

unread,
Mar 25, 2014, 9:31:27 AM3/25/14
to nape-p...@googlegroups.com
Okay, it seem the crash happens when an arbiter is still in the 
body.arbiters list on CbEvent.END - then it will crash when I call body.type = BodyType.STATIC - makes sense as when I make the body STATIC and one more arbiter is left, another interaction will occur on a STATIC object ...

But why is there sometimes an arbiter left in the list on CbEvent.END??? The docs explain: "The End event occurs in the first step in which the objects no longer interact." I thought then all interactions are done ... hm. 

Can someone explain the concept to me?

LiuWong

unread,
Mar 25, 2014, 7:31:31 PM3/25/14
to nape-p...@googlegroups.com
Create a task queue.
To do what you have added to the queue after the simulation step for physics.

Sublinet

unread,
Jun 6, 2017, 6:44:04 AM6/6/17
to Nape Physics
Create a task queue.
To do what you have added to the queue after the simulation step for physics.

I know this was a very long time ago.. but did this solve your issue Michael ?

Thanks
Reply all
Reply to author
Forward
0 new messages