Jump to content

Problem with my player prefab


ZioRed
 Share

Recommended Posts

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

?? FRANCESCO CROCETTI ??

http://skaredcreations.com

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...