Jump to content

[SOLVED] PlayerDummy, setting movement speed


photo

Recommended Posts

How can I set the WASD movement speed for a PlayerDummy object? There is an old question on the forums but that solution no longer applies (set min and max velocity in tools->camera). I can set the WASD speed in the editor bit that's saved in the editor config file not the .world

 

Link to comment

Hi Angus,

You're right, the point is, that the editor camera is handled differently than standard players. Editor player ignores settings set to it via the script; instead, it uses Camera parameters set via the interface, for example, so that artists can change camera settings on the fly. These settings are saved/loaded from/to the configuration file.

You can use a PlayerSpectator or a PlayerActor instead of the PlayerDummy (BTW the player used in the default world, when a new project is created, is a PlayerSpectator). So, here you've got 2 options:

  • in your C++ code create a PlayerSpectator/Actor and set its minimum and maximum velocities via the corresponding methods setMinVelocity()/setMaxVelocity().
  • or, in case if you want velocity settings to be stored in the *.world file, you can create a PlayerSpectator/Actor in the Editor, set necessary velocity values and save the world. Then in your code just set the player via Game::get()->setPlayer(your_player) and the problem is solved.

Here is a simple example in C++:

int AppWorldLogic::init() {	
  // ...
  	// creating a new player
	PlayerSpectatorPtr player = Unigine::PlayerSpectator::create();
	player->setWorldPosition(Math::Vec3(0.0f, 0.0f, 20.0f));
  	
  	// setting velocity values
	player->setMinVelocity(100.0f);// for walk mode
  	player->setMaxVelocity(200.0f);// for run mode
	player->release();
  	// setting our player as a game player
	Game::get()->setPlayer(player->getPlayer());
  
    // ...
}

In case if PlayerDummy (having no methods for managing minimum and maximum velocity values) is the only option for you, you can try to change its transformation manually in the update(), as you would do with any other node by specifying (see the Car::update() method in this usage example).

You can read more on basic movements here.

Hope this helps!

Thanks!

Link to comment
  • silent changed the title to [SOLVED] PlayerDummy, setting movement speed
×
×
  • Create New...