Learn Torque3d - 10 Code Examples & CST Typing Practice Test
Torque3D is an open-source, full-featured 3D game engine focused on real-time 3D development, offering a robust toolset for creating desktop and console games with C++ and scripting support.
View all 10 Torque3d code examples →
Learn TORQUE3D with Real Code Examples
Updated Nov 24, 2025
Code Sample Descriptions
TorqueScript Example - Simple Player Movement
// Define player controls
moveMap.bindCmd(keyboard, "a", "moveleft();", "stopmoveleft();");
moveMap.bindCmd(keyboard, "d", "moveright();", "stopmoveright();");
function moveleft() {
$mvLeftAction = 1;
}
function stopmoveleft() {
$mvLeftAction = 0;
}
function moveright() {
$mvRightAction = 1;
}
function stopmoveright() {
$mvRightAction = 0;
}
A simple TorqueScript snippet showing how to move a player object using key inputs.
TorqueScript Example - Jump Action
// Bind jump key
moveMap.bindCmd(keyboard, "space", "jump();", "stopjump();");
function jump() {
$mvUpAction = 1;
}
function stopjump() {
$mvUpAction = 0;
}
Player jump action with key press.
TorqueScript Example - Shooting Projectile
// Bind shoot key
moveMap.bindCmd(keyboard, "ctrl", "shoot();", "stopshoot();");
function shoot() {
%proj = new Projectile() {
position = Player.getPosition();
velocity = "0 50 0";
};
}
function stopshoot() {
// Nothing for now
}
Player shooting a projectile on key press.
TorqueScript Example - Health Management
// Increase health
function addHealth(%amount) {
$PlayerHealth += %amount;
if ($PlayerHealth > 100) $PlayerHealth = 100;
}
// Decrease health
function removeHealth(%amount) {
$PlayerHealth -= %amount;
if ($PlayerHealth < 0) $PlayerHealth = 0;
}
Increase or decrease player health.
TorqueScript Example - Score System
// Initialize score
$PlayerScore = 0;
function collectItem() {
$PlayerScore += 10;
echo("Score: " @ $PlayerScore);
}
Simple scoring system for collecting items.
TorqueScript Example - Teleport Player
function teleportPlayer(%x, %y, %z) {
Player.setPosition(%x SPC %y SPC %z);
}
// Example teleport
teleportPlayer(0, 0, 10);
Teleport player to a specific location.
TorqueScript Example - Spawn Enemy
function spawnEnemy(%x, %y, %z) {
%enemy = new AIPlayer() {
position = %x SPC %y SPC %z;
};
}
spawnEnemy(20, 0, 0);
Spawns an enemy at a location.
TorqueScript Example - Toggle Light
function toggleLight(%light) {
if (%light.isEnabled()) {
%light.setEnabled(false);
} else {
%light.setEnabled(true);
}
}
// Toggle example
toggleLight(MyLight);
Toggles a light on/off.
TorqueScript Example - Simple Timer
// Schedule function after 3 seconds
schedule(3000, 0, "timerEvent");
function timerEvent() {
echo("Timer finished!");
}
Basic timer example calling a function after a delay.
TorqueScript Example - Player Animation Trigger
// Bind animation key
moveMap.bindCmd(keyboard, "e", "playAnimation();", "stopAnimation();");
function playAnimation() {
Player.playThread(0, "Wave");
}
function stopAnimation() {
Player.stopThread(0);
}
Trigger player animation on key press.
Frequently Asked Questions about Torque3d
What is Torque3d?
Torque3D is an open-source, full-featured 3D game engine focused on real-time 3D development, offering a robust toolset for creating desktop and console games with C++ and scripting support.
What are the primary use cases for Torque3d?
Full 3D game development. Educational 3D simulations. Indie console/PC games. Rapid prototyping in 3D. Custom real-time graphics applications
What are the strengths of Torque3d?
Open-source and fully modifiable. Complete 3D engine with editor. C++ core allows high performance. Flexible scripting via TorqueScript. Good for educational and indie projects
What are the limitations of Torque3d?
Smaller community than Unity/Godot. Outdated in comparison to modern AAA engines. Limited built-in visual scripting compared to modern engines. Editor is less polished than commercial alternatives. Primarily focused on desktop; mobile support is limited
How can I practice Torque3d typing speed?
CodeSpeedTest offers 10+ real Torque3d code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.