Scripting Object Hierarchy
This page is designed to provide an overview of the GameCore Scripting hierarchy and provide a reference to the various classes that are available to you when scripting your games.
The scripting system in GameCore is object oriented. Each class is self-contained and has it's own methods (functions) that you can use the control or manipulate instances of that particular class.
In order to access functions within a specific class (such as the Player class), you first need to get a pointer to the instance of the class that you are working with.
The tree view below shows a high-level overview of the relationship between a few of the classes available to you in GameCore scripting. We'll take a closer look at each of these classes below.

Note that there are additional classes available in GameCore scripting, check the Scripting Reference for more details.
GameManager
The highest level class is the GameManager. For any GameCore application there is only one GameManager available. The GameManager can be thought of as a 'container' for everything that goes on in your application. In other words, it 'manages' your 'game'.
To call any of the functions in a GameCore class or to grab object handles to any object below the GameManager, you must first grab an Object Handle to the GameManager using the GetGameManager() function call like so:
GameManager@ game = GetGameManager();
You can grab an Object Handle to the GameManager in scripts, in your GUI .lay layout files (for event handling calls) and any of the other areas that you can use or call GameCore Script functions (see the Scripting Introduction section for more details on these)
You can also use the GetGameManager() function without explicitly grabbing a seperate object handle - this is useful if you have a one-shot function that you want to call somewhere down the class tree (as show above). For example:
GetGameManager().GetViewport().SetViewToPlayer( "Player");
As you can see here, we don't actually grab a seperate handle to the GameManager, but use the 'dot notation' to travel down the script hierarchy tree to the Viewport class and call a function SetViewToPlayer() from there.
World
The World class is another 'container' class, and is used to access any object within the currently loaded world.
To get a handle to the current loaded world, you first need a pointer to the GameManager(), like so
GameManager@ game = GetGameManager();
To get a pointer to the current world, you call the GetWorld() function, like so:
game.GetWorld();
You can also combine the above two lines into a single call:
GetGameManager().GetWorld();
The World container allows you to set or get properties that are specific to that world. It is also used primarily to access any of the objects within the world (such as the Player and so on). You wouldn't typically call GetWorld() on it's own like we have above, but would use it to get a pointer for a specific object or function within the World, like so:
int objectCount = GetGameManager().GetWorld().GetObjectCount();
In the above example, objectCount would contain the number of objects within the current world.
Viewport
The viewport class controls the main 'window' that displays your game.
Each game has a predefined viewport called 'Main' which refers to the whole screen itself. You can also define any number of sub-viewports within this main display and show or hide these sub-displays at any point during your game.
Some examples of using multiple viewports for a game could include:
- split-screen two player game (like old-school arcade games)
- rear view mirror for a driving game
- picture in picture for mission briefings or communications (such as Ghost Recon Advanced Warfighter)
- 3d Game / World Map (note that Mini-Maps are a seperate feature and are described elsewhere)
To get a pointer to a specific Viewport, you need a handle to the GameManager() container class as described above. the GetViewport() function is a member of the GameManager Class, and can be called like so:
GameManager@ game = GetGameManager(); Viewport@ viewport = game.GetViewport( "Main");
This gets a handle to the entire screen. At the start of your game, the viewport will be located at 0,0,0 within the world, unless you explicitly tell the viewport to attach to an object or player or manually set the viewport's position within the world.
Setting the Viewport to the Player:
SetViewToPlayer()
This function allows you to attach the view to a specific player in the game (of which there can be several).
SetCameraPos( float x, float y, float z); SetCameraTarget( float x, float y, float z); SetCameraFOV( float fov);
The second way to control the Viewport is to manually specify the camera's position & target. This is useful for creating cinematics or in-game cutscenes for example. Refer to the 'Missions & Cinematics' section for more details on how to use these functions.
Player
A player is a special type of object that can have an inventory (so they can pickup items) and receive proximity events (triggers). You can have any number of players within a game world and each player has an independent inventory.
You can create a player in one of two ways.
Option 1 : 'Make Player'
The first is to check the 'Make Player' checkbox for the object in the editor. This will automatically make that object a player. In this case, the player becomes the name of the object in the editor.
Option 2 : Create a Player from Script
The second method is to manually create the player via script:
// 1) get a pointer to the game manager
GameManager@ game = GetGameManager();
// 2) create a player of name "Player"
Player@ player = game.CreatePlayer( "Player", true);
// 3) get a pointer to the object that we want to be associated with this player
Object@ playerObject = game.GetWorld().GetObject( "SoldierGuy");
// 4) add the object to the player's inventory
player.AddToInventory( playerObject);
// 5)set the viewport to our new player, like so:
game.GetViewport( "Main").SetViewToPlayer("Player");As you can see, this second method requires that you create a player and then add a specific object to the player's inventory prior to attaching the viewport.
In order to simplify the process of creating the player, you can use the first method, and simply check the 'Make Player' checkbox in the editor, which does steps 2 through 4 automatically for you.
A player by default does not have an actual 3d model attached - in fact, a GameCore game does not specifically have to have a viewable 3d model as the player (useful for Sim or 'God' type games like Populous for example).
Getting a handle to a player is done through the World class. In order to get a pointer to a specific player, you need to know which object in the game is a part of that player's inventory.
So for example, if you have 2 players in a world, one with the object Soldier1 and the other with object Soldier2 in their inventories, you would first get a handle to the world (via GetWorld(), and then call GetPlayer() for each of the object names, like so:
Player@ player1 = GetGameManager().GetWorld().GetPlayer("Soldier1");
Player@ player2 =GetGameManager().GetWorld().GetPlayer("Soldier2");This would return a pointer of type 'Player@', which you can then use to call any of the player class functions.
You can also use a pointer to the Object itself instead of using their Name if you have it:
// First get a pointer to the object Object@ playerObject = GetGameManager().GetWorld().GetObject( "SoldierGuy"); // get a pointer to the player associated with the object Player@ player = GetGameManager().GetWorld().GetPlayer( playerObject);
ControllerCamera
The ControllerCamera class is a special purpose class that is only used by scripted controllers. A scripted controller is an object in a world that has a script attached to it (such as the player or a vehicle). Each script can override and control the game camera during the game.
You do not specifically need to get a pointer to the controller Camera, it is automatically passed into the SetupCamera() function available to controller scripts:
void SetupCamera( Object@ object, Viewport@ viewport, ControllerCamera@ camera)
{
}FXManager
The FXManager provides an interface to the built-in effects system. It is a stand-alone class that doesn't require that you store a pointer to it, and is accessible via the global function GetFXManager().
The most common thing that you would want to do with the FX Manager is spawning effects, which can be done like so:
GetFXManager().CreateFXAtPosition( "../../fx/explode1.fxt", value);
Where 'value' is a vector of the location you want to spawn the effect.
Object
This class is used to operate on an GameCore object on a whole (as opposed to individual meshes or surfaces within the object), for example:
GetGameManager().GetWorld().GetObject("ObjectName");When working with Controller Scripts, each of the controller functions are automatically passed in the object that the script is attached to.
ObjectMesh
Object Mesh is used to manipulate individual meshes within an object. For example, a vehicle would typically have a 'Body' mesh and separate meshes for each of the Tires.
GetGameManager().GetWorld().GetObject("ObjectName").GetMesh("MeshName");ObjectBase
GetGameManager().GetWorld().GetObject("ObjectName").GetObjectBase("Name");Light
GetGameManager().GetWorld().GetObject("ObjectName").GetLight("LightName");ObjectCollide
GetGameManager().GetWorld().GetObject("ObjectName").GetCollideObject("CollideObjectName");ObjectJoint
GetGameManager().GetWorld().GetObject("ObjectName").GetJoint("JointName");Surface
GetGameManager().GetWorld().GetObject("MyObject").GetMesh("MyMesh").GetSurface("MySurface");Matrix
GetGameManager().GetWorld().GetObject("MyObject").GetObjectBase("MyMesh").GetMatrix();
GetGameManager().GetWorld().GetObject("ObjectName").GetCollideObject("CollideObjectName").GetMatrix();
GetGameManager().GetWorld().GetObject("MyObject").GetMesh("MyMesh").GetMatrix();
