Building a Game with
Unity3D
changes to example script
var myrigidbody:Rigidbody; // declare a variable of proper type
myrigidbody=GetComponent(Rigidbody); // note javascript uses () instead of < >
myrigidbody.AddRelativeTorque …
+make a game with unity +brackeys
•
•
•
•
•
•
•
•
•
•
•
Unity Basics
make a game - 1
make a game - 2
Make a game- 3
make a game - 3b - camera
Make a game - 5 - shadows + respawn
make a game - 5a - jumping
make a game - 6 - quality settings
make a game - 7 – collectibles
make a game - 8 - animation
many more videos: use the search in the title above
moving a sphere
function Start () {
// saved for posterity
queriesHitTriggers=true;
blue_rotation = Input.GetAxis ("Horizontal") * rotationSpeed * -1 ;
blue_rotation*=Time.deltaTime;
rgdblue= GetComponent (Rigidbody);
rgdblue.velocity = new Vector3 (.1*rotationSpeed * Time.deltaTime, 0) ;
rgdblue.velocity=rgdblue.velocity*-1;
rgdblue.AddRelativeTorque (Vector3.forward * blue_rotation); //vector3 is 3D mgmt
}
function Update()
{
blue_rotation = Mathf.Abs(Input.GetAxis ("Horizontal") * rotationSpeed ) *-1;
blue_rotation*=Time.deltaTime;
rgdblue=GetComponent(Rigidbody);
rgdblue.AddRelativeTorque (Vector3.forward * blue_rotation); //vector3 is 3D mgmt
}
Tips
• A rotation completely describes an object's absolute orientation (or a change in
orientation).
• A direction specifies which way an object is pointing or facing, NOT it's movement
direction (a rotating car on ice can be moving in direction x, but facing direction y.)
• Rotations and Directions are (not easily) convertible into each other. But they have
different characteristics when it comes to combining and comparing them.
• You can add two Rotations and get a new rotation:
90 degrees + 90 degrees = 180 degrees.
• But if you add two direction vectors you get a new vector that doesn't express a rotation
any more. It is possible to 'convert' a direction to a rotation, but since the mapping is not
one-to-one, you have to introduce additional constraints in order to arrive at a unique
result. (This is basically what functions like the quaternion LookRotation() function do.)
• Rotations are Quaternions
• If you want to rotate around the world's "up" direction, regardless of the object's local
coordinate system, you can try adding Space.World as the last argument to Rotate
© Copyright 2026 Paperzz