Physical engine callback function problem

In my game,a box should fall on the ground firmly.But, iIt will keep a slight jump, sometimes suddenly jump. Same as cpp-tests in Node:physical. In the past two days only once was normal. I found it probably because onContactBegin(…) was repeatedly called. Is it just me?
Thanks for any help.

v3.5 visual studio 2013

You mean the box will bounce? Have you checked the restitution for your box’s physics body?

Unless your onContactBegin does something to affect the velocity or force of the physics body, it should not affect the box’s physical movement.

Thanks.
restitution: PhysicsMaterial(0.0f, 0.0f, 0.0f)
My onContactBegin doesn’t do anything except log (“onContact!”).
But the box still bounce.

Does the box fall due to gravity or under some applied forces or velocity?

Just for comparison, here’s my code to create such scenario:

	Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();

PhysicsBody* body = PhysicsBody::createEdgeBox(visibleSize, PHYSICSBODY_MATERIAL_DEFAULT, 3);
body->getShape(0)->setRestitution(0.f);
Node* edgeNode = Node::create();
edgeNode->setTag(0);
edgeNode->setPosition(Point(visibleSize.width/2,visibleSize.height/2));
edgeNode->setPhysicsBody(body);
addChild(edgeNode);


Node* sprite = Node::create();
sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
sprite->setContentSize(Size(30,30));
PhysicsBody* body1 = PhysicsBody::createBox(sprite->getContentSize());
body1->getShape(0)->setDensity(1.f);
body1->getShape(0)->setFriction(0.f);
body1->getShape(0)->setRestitution(0.f);

sprite->setPhysicsBody(body1);
sprite->setPosition(Vec2(384,300));
this->addChild(sprite);

Hope it will help you somehow.

Your code is the same as mine!
I copied it and tested it in my project. The result is the same as mine,Like the GIF above. The box still continues to rebound.
Will the box stay on the ground in your project?

Thank you anyway!

P.S. My English is not so good

What physics engine are you using?

This reply is a little late.
3.x physical engine. You can run node:physics in cpp-tests.I use it.

http://www.cocos2d-x.org/programmersguide/12/index.html

@0x5f375a86 if I were you I’d use Box2D, is a lot better, just my opinion

@UKDeveloper99 Thank you, I’ll think about Box2d. :smile: