Jump to content

Problems with console callbacks


photo

Recommended Posts

Hi, I've added a few console commands.  But the only one that works is the one with no arguments.  The console commands I've added with arguments don't work.  Could you help me figure out what I've done wrong?

 

Here's a callback:

 

 

 

class SetCameraTargetCallback : public CallbackBase3<double, double, double>

{

  void run (double x, double y, double z)

  {

    Log::message("Testing...\n");

    PlayerSpectatorPtr player = PlayerSpectator::create(Game::get()->getPlayer());

    Vec3 camPos(x,y,z);

    player->setNodeWorldPosition(camPos);

  }

}

SetCameraPosCallback setCameraPosCallback;

 

 

 

And then in my code just after I initialize the engine:

 

Console::get()->addCommand("set_camera_pos", "Sets the camera position", &setCameraPosCallback);

 

Then once in game, opening the console window and using the ls command will list my new commands,

but executing them does nothing.

 

Unigine~# set_camera_pos 100 100 100

 

It doesn't print out "Hello", doesn't move the camera, nothing.

 

But then if I call the show_nodes command I added, it works just as expected.

 

Thanks

Link to comment

Hi Silent,

 

Specifically, I want to have a console command for setting the camera target, position and fov.  The current command sets position and euler angles, which is fine but doesn't fit our needs.  We specifically want to be able to set the camera using a target. 

 

Anyways, thanks, I read the post and I'll try that out.

Link to comment
×
×
  • Create New...