FlyThrough

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Text replace - "<javascript>" to "<syntaxhighlight lang="javascript">")
m (Text replace - "</javascript>" to "</syntaxhighlight>")
 
Line 23: Line 23:
 
transform.position += transform.right*moveSpeed*Input.GetAxis("Horizontal");
 
transform.position += transform.right*moveSpeed*Input.GetAxis("Horizontal");
 
}
 
}
</javascript>
+
</syntaxhighlight>

Latest revision as of 20:52, 10 January 2012

Author: Slin

[edit] Description

This is just a very basic fly through camera movement javascript code.

var lookSpeed = 15.0;
var moveSpeed = 15.0;
 
var rotationX = 0.0;
var rotationY = 0.0;
 
function Update ()
{
	rotationX += Input.GetAxis("Mouse X")*lookSpeed;
	rotationY += Input.GetAxis("Mouse Y")*lookSpeed;
	rotationY = Mathf.Clamp (rotationY, -90, 90);
 
	transform.localRotation = Quaternion.AngleAxis(rotationX, Vector3.up);
	transform.localRotation *= Quaternion.AngleAxis(rotationY, Vector3.left);
 
	transform.position += transform.forward*moveSpeed*Input.GetAxis("Vertical");
	transform.position += transform.right*moveSpeed*Input.GetAxis("Horizontal");
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox