I made two versions, one looks left the other looks right. Implemented a change of direction with the removal of the body and create a new one.
But on low laptop the game freezes at the moment of reversal.
How did you solved this problem? Maybe I need both versions of the body load while a second body to do not active? Then rearrange them and do not active the first body. Or to throw from World1 to World2 ?
Rotation of an object in the other side
-
- Posts: 25
- Joined: Tue Sep 19, 2017 4:30 pm
Re: Rotation of an object in the other side
We Can take all the fixtures and replace them with other forms (shapes). Then take the connection information and recreate connections with recalculated data but will it be faster??? Loader Json makes this way of the files.
Re: Rotation of an object in the other side
What language are we talking about?
If you run your program as as debug build, you should be able to use the debugger to step into the code while it is running to see what it is doing.
Is it just a single body you want to flip? Replacing the whole body could be a lot of trouble because you need to manually set the velocity, rotation, angular velocity etc. Yes, it would be better to have two sets of fixtures, and switch between using different fixtures.
If you want to flip multiple bodies (and a structure of joints) then you will need to replace all the bodies. I don't think the result will look very good...
If you run your program as as debug build, you should be able to use the debugger to step into the code while it is running to see what it is doing.
Is it just a single body you want to flip? Replacing the whole body could be a lot of trouble because you need to manually set the velocity, rotation, angular velocity etc. Yes, it would be better to have two sets of fixtures, and switch between using different fixtures.
If you want to flip multiple bodies (and a structure of joints) then you will need to replace all the bodies. I don't think the result will look very good...
-
- Posts: 25
- Joined: Tue Sep 19, 2017 4:30 pm
Re: Rotation of an object in the other side
![Image](https://wmpics.pics/di-DCLM.gif)
Code: Select all
b2dJson jsonR;
jsonR.readFromFile("obj/car_r.json", errorMsg, &World);
b2dJson jsonL;
jsonL.readFromFile("obj/car_l.json", errorMsg, &World);
Code: Select all
->SetActive(false);
->SetActive(true);
Code: Select all
->GetPosition();
->GetAngle();
->GetLinearVelocity();
->SetTransform(pos, angle);
->SetLinearVelocity(speed);
Re: Rotation of an object in the other side
Yes, I think that would work ok.