Jump to Main Content
Jump to Main Content

BlinkScript Game Navigation Code Example



Description


This code example shows how to use game navigation. Use the mouse to look around and the W,S,A and D keys to move. All the code and assets are in the projects Scripts directory. You can download the project using the link above.

PostWorld.js


// Turn on debug so that Chat.printDebug() and Chat.dump() work
Chat.debugOutput = true;

// Display the stats panel in the bottom left corner of screen
Application.statsVisible = true;

// Turn on collisions, but allow the user to turn it off
Actor.setCollisionSetting( true, false );

// Turn on gravity, but allow the user to turn it off
Actor.setGravitySetting( true, false );

// Show the avatar
Actor.showAvatar  = false;

// Show the chat panel
Application.chatPaneVisible = false;

// Set ambient light for the scene
Scene.ambientLightColor = Color(0.5, 0.5, 0.5, 0);

// Create a point light over the oger head to give meanacing look
var oPointLight = Scene.createPointLight( "SceneLight" );
oPointLight.position = Vector( 0, 600, -500 );

// Create the floor
var oGround = Scene.createGround( "MainFloor", "RustySteel", 3000.0, 3000.0, true );

// Create a Skydome
oSkyDome = Scene.createSkyDome();
oSkyDome.materialName = "CloudySky";
oSkyDome.curvature = 5;
oSkyDome.tiling = 8;
oSkyDome.distance = 4000;
oSkyDome.enable = true;

// Add the Ogre head
oHeadEntity = Scene.createEntity( "OgreHead", "ogrehead.mesh" );
oHeadNode = Scene.createSceneNode( "OgreHeadNode" );
oHeadNode.attachObject( oHeadEntity );
oHeadNode.position = Vector( 0, 100, -500 );

// Give the Ogre head some physics
oHeadEntity.collisionGeometryType = oHeadEntity.COLLISION_GEOM_BOX;
oHeadEntity.createPhysicalModel();

// Set the navigation style to game
Actor.navigationStyle = Actor.NAVIGATION_STYLE_GAME;



Related BlinkScript Examples
?????? ?????? ?????? ??????