b2Body SetUserData() error
Posted: Fri Aug 23, 2013 9:47 pm
Hi,
when loading in my RUBE scene I am trying to do some extra processing afterwards by creating some specific game objects and attaching them to the appropriate b2Body objects via body->SetUserData(myObj);
When running a world physics step the app crashes with a segmentation fault. This only happens if I try to attach to the body. If attach my user data to one of its fixtures it runs ok.
Referring to the sample loaders, I am doing this in the afterLoadProcessing() method
e.g)
Is there something wrong with trying to attach to the body?
Thanks for the help
when loading in my RUBE scene I am trying to do some extra processing afterwards by creating some specific game objects and attaching them to the appropriate b2Body objects via body->SetUserData(myObj);
When running a world physics step the app crashes with a segmentation fault. This only happens if I try to attach to the body. If attach my user data to one of its fixtures it runs ok.
Referring to the sample loaders, I am doing this in the afterLoadProcessing() method
e.g)
Code: Select all
afterLoadProcessing(b2dJson* json) {
// this will result in a crash when world->Step() is called first time
b2Body* body json->getBodyByName("mybody");
body->SetUserData(myObj);
// this works
b2Fixture* fixture json->getFixtureByName("myfixture");
fixture->SetUserData(myObj);
}
Thanks for the help