Skip to content

how to use Physics subsystem in Skylicht #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bendico1 opened this issue Aug 18, 2024 · 1 comment
Open

how to use Physics subsystem in Skylicht #185

bendico1 opened this issue Aug 18, 2024 · 1 comment

Comments

@bendico1
Copy link

Hi,
I 'm experimenting with the Physics subsystem: I loaded two game objects in .dae format, a box scaled along x and y axes to resemble a ground plane and a sphere. My idea is that the sphere, located a little bit in the air, falling down towards the floor at runtime. I'm using Linux Os and Code::Blocks as IDE.
But the simulation doesn't run, there is a segmentation fault.

This is the workflow I used for this purpose:

//create an instance of the Physics subsystem in MyGame.h
Physics::CPhysicsEngine* myPhyx = Physics::CPhysicsEngine::getInstance();

Then in MyGame.cpp:

// Physics initialization
myPhyx->initPhysics();

//Physics stuff for plane
plane->addComponent<Physics::CStaticPlaneCollider>();
Physics::CRigidbody* planeRB = plane->addComponent<Physics::CRigidbody>();
planeRB->setDynamic(false);
planeRB->initRigidbody();
planeRB->setPosition(core::vector3df(0, -1, 0));
planeRB->syncTransform();

//Physics stuff for sphere
sphere->addComponent<Physics::CSphereCollider>();
Physics::CRigidbody* sphereRB = sphere->addComponent<Physics::CRigidbody>();
sphereRB->setDynamic(true);
sphereRB->initRigidbody();
sphereRB->setPosition(core::vector3df(0, 4, 0));
sphereRB->syncTransform();

// update application in Update() Method
float timestepSec = getTimeStep() / 1000.0f;
myPhyx->updatePhysics(timestepSec);
m_scene->update();

What's wrong?
Which is the right implementation?
Thanks for you kindly support.

@ducphamhong
Copy link
Contributor

Hello @bendico1
Sorry for the late response
I think I have fixed this bug segmentation fault in CRididBody.cpp
Can you update last update, or can you share me the source .cpp file.
Thanks you,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants