rstralberg
Member
|
Why "Physics.startSimulation().stopSimulation();"
Hi
Not a problem. All works fine. However there is a line in the Grab-sample that I don't understand why its there. Its the Physics.startSimulation().stopSimulation();.
Code:
bool Update()
{
if(Kb.bp(KB_ESC))return false;
Physics.startSimulation().stopSimulation();
if(Kb.ctrl()) // if want to grab
{
if(!grab.is()) // if not yet grabbing
{
grab.create(obj, Vec(0, 0.3, 0), 10); // start grabbing 'obj' actor at (0,0.3,0) local position with a power of 10
}
if(grab.is()) // if grabbing something
{
// drag the object to left/right/forward/backwards
Vec dir(0);
if(Kb.b(KB_LEFT ))dir.x--;
if(Kb.b(KB_RIGHT))dir.x++;
if(Kb.b(KB_DOWN ))dir.y--;
if(Kb.b(KB_UP ))dir.y++;
grab.pos(grab.pos()+dir*Time.d()*2);
}
}else
{
if(grab.is())grab.del();
}
return true;
}
|
|
06-19-2015 06:40 PM |
|
RedcrowProd
Member
|
RE: Why "Physics.startSimulation().stopSimulation();"
i'm not sure, but:
PhysicsClass& startSimulation(Flt dt=Time.d()); // start frame simulation !!
PhysicsClass& stopSimulation( ); // get results of simulation !!
so i would say, its in case of physic ( like actor ) case, that youll need it to have the result of the current frame but i might be wrong
|
|
06-19-2015 07:28 PM |
|
rstralberg
Member
|
RE: Why "Physics.startSimulation().stopSimulation();"
Aha. So its actually a way to calculate physic and directly get the results.
|
|
06-19-2015 07:31 PM |
|
RedcrowProd
Member
|
RE: Why "Physics.startSimulation().stopSimulation();"
should be, maybe someone that knows more about physic can confirm
(if you comment this line, the simulation wont work, so to my understanding its this )
|
|
06-19-2015 08:17 PM |
|
Pixel Perfect
Member
|
RE: Why "Physics.startSimulation().stopSimulation();"
My understanding is that this needs to be called to run the physics simulation. Without this being called no physics will be calculated.
It's not normally called directly as its actually called by world:update under normal situations.
|
|
06-19-2015 08:28 PM |
|
Esenthel
Administrator
|
RE: Why "Physics.startSimulation().stopSimulation();"
Hello,
This updates the Physics simulation.
Yes Game.World.update calls this on its own. I think this is included in Game.World.update comments.
|
|
06-20-2015 12:17 AM |
|
rstralberg
Member
|
RE: Why "Physics.startSimulation().stopSimulation();"
Thanks guys for the explanation.
|
|
06-20-2015 01:03 AM |
|