Jump to content

I have playeractor problem


photo

Recommended Posts

hi , i'm studying for Unigine.

i have a problem. I saw sample ' actor01' and i knew playeractor is need to move physics playermoving.

playeractor works when playeractor pivot is appeared in my camera. However,  playeractor pivot is not in my camera , playeractor doesn't work.

please help me how can i solve it. 

Link to comment

Hi killsmarine,

Sorry, but could you provide a little bit more detailed description of what you are trying to do. I also need a small sample with your code to understand your problem and help you.

Thanks!

Link to comment
node = node_find(_strNodePath);
 if (node && node.get())
 {
  m_Mesh = ObjectMeshSkinned::cast(node);
  if (IsValidMesh())
  {

   m_Mesh->setNumLayers(eHorseAnimation::ANI_END);
   for (int i = 0; i < eHorseAnimation::ANI_END; ++i)
    m_Mesh->setAnimation(i, ("Horse_World/ani/" + HORSE_ANI_NAME).c_str());

   m_playerActor = PlayerActor::create();
   m_playerActor->setWorldTransform(m_Mesh->getWorldTransform());
   m_playerActor->setMinThetaAngle(-80.0f);
   m_playerActor->setMaxThetaAngle(80.0f);
   m_playerActor->setThetaAngle(20.0f);
   m_playerActor->setMaxFriction(m_playerActor->getMinFriction() * FRICTION_SENSITIVITY);
   m_playerActor->setPhysicalMass(m_playerActor->getPhysicalMass() * PHYSICAL_MASS_WEIGHT);
}
 
void Update()
{
 m_Mesh->setWorldTransform(m_playerActor->getWorldTransform() * Math::rotateZ(90.0f));
}
 
 
first,  i load objetMeshSkinned and Create PlayerActor.
second, i set playeractor transform to mesh.
i change camera transform when mesh is moving.
it is playing well when PlayerActor is in Camera ,but PlayerActor isn't in Camera, PlayerActor is not Moving.
i made this situation in sample 'actor01', and it doesnt work.
sorry, my englsih skill is not good. i'm not sure you understand what i am saying.
Link to comment

Hi killsmarine,

Don't worry about your English, it's ok!

Ok, so you have a PlayerActor, an ObjectMeshSkinned and some other Player(camera). In the update() method you set the position of the ObjectMeshSkinned equal to the position of the PlayerActor.

But who controls PlayerActor's movement? Do you control PlayerActor's movement using the keyboard or do you use the ControlsDummy Class?

You also said that you "change camera transform when mesh is moving", how do you do that?. Do you use setWorldTransform() or do you change current player using the Game::setPlayer() method(in this case the PlayerActor will no longer be controlled)?

 

Could please you provide a small scene with the source code for better understanding of your case?

Link to comment
×
×
  • Create New...