Jump to content

Create 1st Person Character


photo

Recommended Posts

Is there a quick method in creating first person character? Assuming it is using playerActor / Persecutor.. for a simple example using script based project how would add the character? Really need to show first person walking around quickly so any help would be gracious to you!

Link to comment

Hi Mike,

You can check any of our demos that are made for first-person usage (for example, Superposition or Oil Refinery) if you need a C++ solution.

The easiest way to add pre-defined PlayerActor is to modify world script of newly created project (located in <YourProject>/data/<YourProject>.usc). Just change 8 line to the following:

PlayerActor player = new PlayerActor();

Thanks!

  • Like 1

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Yes, thats working quite easily.
 

Be sure, that you turn on the Physic simulation and switch to the 'Engine' window. Then you can use this 'camera' as a first person player.

Just as an idea:

For many purposes it would be very handy, to have a 'player' - out of the box as a template.
So a human character attached with basic movement animation for walking running, jumping, switching to 3rd person camera.

First steps towards implementing content and testing it would be very quickly achievable, for human scaled projects e.g. Architectural viz, landscape etc.

Edited by werner.poetzelberger
  • Like 1
Link to comment

As far as getting to know this engine, which is day 1 of license FYI :) If I wanted to interact with a '"Trigger area/box" for debugging purposes and turn a omni light on or move a box from one point to another after player collides with trigger. What do you think is best way to achieve this, obviously examples I will look at I just like to start with the simple things first.

Link to comment

Hi Mike,

The simplest way to do this for a project in UnigineScript would be as follows:

  1. Open your world the UnigineEditor
  2. Create an omni light source (Create->Light->Omni) named "LightOmni"
  3. Create a world trigger (Create->World->Trigger), set its size to 2 and position to (0.0, -2.0, 1.01)
  4. Insert the following code to the world script of you project (located in <YourProject>/data/<YourProject>.usc)
    // material ball
    Node mball;
    
    // omni light source
    LightOmni light;
    
    
    // function to be called when a node enters the trigger
    void trigger_enter_callback()
    {
    	// enabling our light
    	light.setEnabled(1);
    	
    	// changing the position of the material ball
    	mball.setPosition(Vec3(0.0f, 0.0f, 0.5f));
    }
    
    // function to be called when a node leaves the trigger
    void trigger_leave_callback()
    {
    	// disabling our light
    	light.setEnabled(0);
    	
    	// changing the position of the material ball
    	mball.setPosition(Vec3(0.0f, 0.0f, 0.0f));
    }
    
    int init() {
    	// Write here code to be called on world initialization: initialize resources for your world scene during the world start.
    	
    	//creating a player actor (1st person)
    	Player player = new PlayerActor();
    	player.setPosition(Vec3(0.0f,-5.5f,1.5f));
    	player.setDirection(Vec3(0.0f,1.0f,-0.4f));
    	player.setControlled(1);
    	engine.game.setPlayer(player);
    	
    	// getting a material ball node
    	mball = engine.editor.getNodeByName("material_ball");
    	
    	// getting an OmniLight node
    	light = node_cast(engine.editor.getNodeByName("LightOmni"));
    	
    	// setting initial state of the light to disabled
    	light.setEnabled(0);
    	
    	return 1;
    }
  5. On the World Trigger tab of the Parameters window specify callbacks to be called when entering and leaving the trigger (see the attached image)
  6. Launch your project and enjoy!

For more information on creating and using WorldTriggers via code, please check out the following samples included in the SDK (You can access them from the Samples tab of the SDK Browser):

  • Samples/C++ API/Nodes/WorldTrigger
  • Samples/UnigineScript/World Management/trigger_00 - trigger_02

Hope this helps!

Thanks!

trigger_callbacks.png

  • Like 1
Link to comment

Fox,

Thanks for the response worked fine as I already had playerActor just inserted code around it, figured it had to do with enter/leave callback on trigger node, just wasn't sure how to implement with World Script. The intention is push the limit with scripting and see how much can be accomplished sans C++ direct compiling. Specifically for fast prototyping and more it seems the samples are all C++ files however maybe reading wrong since header and .cpp files can also contain scripts?  I'm also thinking world expressions can be attached to many nodes and things... If anyone has further information that shows examples of creating similar interactivity as Superpostion/OP (such as picking up items, interacting to open close doors etc.., goals and menu saving optins) but using solely scripting I'd be interested. Still trying to work it out on my own however :) Would be able to save this data and reload it via a GUI would be top priority.

Link to comment

Glad it worked for you, Mike!

About scripts and C++ (if I got your question right): the point is that script files in UnigineScript samples may have .cpp extension (this was used earlier for automatic syntax highlighting), but actually they are not C++ files (since 2.7.2 .cpp extension for scripts was replaced with .usc). So, you can't directly include and use them in your C++ project as you would normally  do with ordinary C++ code. You can combine C++ and scripting - this section may be helpful in such a case.

As for VR Template you can copy it as a project, and use to build your own application, but in C++. The VR Template uses the Component System which is not available in UnigineScript at the moment. You can check out the following UnigineScript samples included in the SDK (You can access them from the Samples tab of the SDK Browser):

  • Samples/UnigineScript/Plugins/app_oculus_00
  • Samples/UnigineScript/Plugins/app_vive_00

And then try to implement the desired interactivity in UnigineScript (using VR Template as an example), either in pure script or in combination with C++ code (see the link above).

You can also check out information on adding scripts to your project here (with an example of using a WorldExpression).

Thanks!

 

Link to comment
  • 7 months later...

I am returning to this topic as haven't been working with Unigine in some time because of life / work / kids, however have some time to focus and the intention is to get a First Person Exploration/Puzzle  project up and running. The concept is walking through (varied environments) in simple story mode fixing stuff etc, possibly a simple inventory and main menu to save stuff... (not trying to win awards here, this is a learning project really).

The barriers to entry for me are creating the First Person Character though!! I have tried to replicate the superposition and oil refinery systems and seems there is ALOT of extra VR relevant info in there in which I do not need. I am also not sure how to implement the Unigine script examples as it seems they are all pointing to a header file that needs to be there? If there is anyone WILLING to help me out here would even consider Paypal-ing for your time to get few things up and running. My experience is in UE4 and Cryengine however wish to seriously learn Unigine for future project ideas....

Prior thanks to who answers this :)

Mike

Link to comment

Not completely like that no, The Witness focused on repetition and maze puzzles. I like working with physics actually, colors, text and info type puzzles. My 3d work is on this page and have a game on Steam already www.z3roram.com

And to be clear, sure there are TONS of packs in Unity?Unreal that you can customize and do this stuff straight out of the box, however I feel they all look alike and the innovation seems to be limited for indie devs. I like the idea of using creativity and replicating if at all possible.

Edited by mike.mcg
Link to comment
×
×
  • Create New...