This page has been translated automatically.
Программирование
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Running Tracker in Game

After the track-based animations were created in the editor, they need to be played in the game. To add this functionality to your project, add the following code into the world script (my_world_name.cpp):

Source code (UnigineScript)
#include <core/systems/tracker/tracker.h>

/*
 */
Unigine::Tracker::TrackerTrack track;
float time, min_time, max_time, unit_time;

/*
*/
int init() {

	// Use Tracker namespace.
	using Unigine::Tracker;

	// Create a Tracker that will play track animations.
	Tracker tracker = new Tracker();
	// Load the created Tracker tracks from file.
	track = tracker.loadTrack("samples/tracker/tracks/render_00.track");
	
	// Get the start time of the Tracker (in units).
	min_time = track.getMinTime();
	// Get the end time of the Tracker (in units).
	max_time = track.getMaxTime();
	// Get the duration of Tracker unit (in seconds).
	unit_time = track.getUnitTime();
	
	// Set the initial time to play tracks animation.
	time = track.getMinTime();

	return 1;
}

/*
*/
int update() {
	
	if(track == NULL) return 1;
	
	// Update the tracks animation time.
	time += engine.game.getIFps() / unit_time;
	time = min_time + ((time - min_time)) % (max_time - min_time);
	
	// Set animation time for tracks.
	if(engine.game.isEnabled()) track.set(time);
	
	return 1;
}
Last update: 03.07.2017
Build: ()