Force2D

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
 
(JavaScript - Force2D.js)
Line 10: Line 10:
 
  }
 
  }
 
   
 
   
  function Update ()
+
  function FixedUpdate ()
 
  {
 
  {
 
  transform.position.x = depth;
 
  transform.position.x = depth;

Revision as of 18:42, 1 December 2005

Author: Jonathan Czeck (aarku)

Description

Usage

JavaScript - Force2D.js

var depth = 0.0;

function Awake()
{
	depth = transform.position.x;
}

function FixedUpdate ()
{
	transform.position.x = depth;
	fwd = transform.localRotation * Vector3.fwd;
	fwd.x = 0;
	transform.localRotation = Quaternion.LookRotation (fwd, -Vector3.Cross (Vector3.right, fwd));
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox