@majinbui wrote:
I am currently having issues with a duplicate PhysicsBody left at the starting position of the sprite. The PhysicsBody that stays at the original location stays active and disables when
_sprite->getPhysicsBody()->setEnabled(false);
is called.
Here is how the PhysicsBody is created:
auto spriteSize = _sprite->getContentSize(); auto physicsBody = PhysicsBody::createEdgeBox(Size(spriteSize.width, spriteSize.height), PhysicsMaterial(0.1f, 1.0f, 0.0f)); physicsBody->setDynamic(true); physicsBody->setCategoryBitmask((int)PhysicsCategory::CAR); physicsBody->setCollisionBitmask((int)PhysicsCategory::None); physicsBody->setContactTestBitmask((int)PhysicsCategory::Tokens); _sprite->setPhysicsBody(physicsBody); _sprite->setUserData((void*)this);
How the body is moved:
_sprite->getPhysicsBody()->setVelocity(velocity);
An example of the issues is shown below in the gif included.
If you need any information/code snippets to help debug, please don't hesitate to ask.
Thanks for any assistance!
Posts: 2
Participants: 1