ZioRed Posted June 8, 2013 Posted June 8, 2013 I have a prefab for my player like this: http://imageshack.us/f/46/leplayerprefab.png/ "Player" in the hierarchy is a pivot, while the SKIN_MESH is the barbarian .mdl, with mass 0, since the real physics properties are set on the pivot. The prefab is loaded of course through Prefab::Load and I'm trying to use PhysicsSetPosition and PhysicsSetRotation to move it around by key presses: float move = 0; float turnspeed = 2 * Time::GetSpeed(); if (App::instance->window->KeyDown(Key::Up)) move = 2; else if (App::instance->window->KeyDown(Key::Down)) move = -2; if (App::instance->window->KeyDown(Key::Right)) movement.y += turnspeed; else if (App::instance->window->KeyDown(Key::Left)) movement.y += turnspeed; Vec3 pos = model->GetPosition(); model->PhysicsSetPosition(pos.x, pos.y, pos.z + move * Time::GetSpeed(), 0.5); model->PhysicsSetRotation(movement.x, movement.y, movement.z, 0.5); ..but it does not move or rotate. I tried to use similar code with an entity created through code (like in the reference page) and it works there, so what is the problem? Cannot I use this code with a pivot having physics? Thanks Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com
YouGroove Posted June 8, 2013 Posted June 8, 2013 Is the mass correct for the object ? sometimes this is the problem also. Quote Stop toying and make games
ZioRed Posted June 8, 2013 Author Posted June 8, 2013 Yes I printed to console the values of move and mass and they're correct but PhysycSetPositions does not change the position there Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.