Jump to content

Creating Player Actor


photo

Recommended Posts

Hi everyone, nice to meet you all :) .

 

I am currently trying to create a Player Actor with the capsule collider - but nowhere in the docs or on these forums can I find how I can create one and place it in the world I'm working on - any help would be great, thank you!

Link to comment

Hi Johnny!

 

Unfortunately, you can't add and use the Player Actor to the world via UnigineEditor. Player Actor for now is only run-time use player, and you should work with it via code.

 

Actually, you can add it to the editor, but it's better to work with them via code.

If you want to add it by means of UnigineScript, see usage examples in our samples: 

  samples/players/actor_00.cpp

  samples/players/actor_01.cpp

 

Sorry for inconvenience caused.

Link to comment

oh ok, i thought i was missing something very basic :P . thanks a lot! also at the moment is the only way to specify where the actor spawns is via hard coding coordinates or is it possible to grab the transform from a dummy and spawn it there?

Link to comment

I'm not sure that I understood your question correctly, please, provide some information about grabbing the transform of dummy if the answer is not what you're asking for.

In UnigineScript, you can get the position of dummy node (or player dummy), get its transformation matrix and set it to PlayerActor:

// get the PlayerDummy node by its name in editor
Node playerDummy = engine.editor.getNodeByName("dummy");
// set transformation matrix of the dummy player to the actor
actor.setTransform(playerDummy.getTransform());

If you need the functions of Player class, simply cast the node to the player after getting it:

// get the player dummy object
PlayerDummy playerDummy = node_cast(engine.editor.getNodeByName("dummy"));

P.S. engine.editor functions allow you to get node by name, id or get the current editor player.

 

Thanks!

Link to comment
×
×
  • Create New...