OldSchoolSteering

From Unify Community Wiki
Revision as of 17:50, 29 December 2012 by Save (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Author: Lars-Erik Jakobsson (save)

Description

Assigns a new forward direction on a transform from horizontal- and vertical input to get eight rotation directions.

JavaScript - OldSchoolSteering.js

function Update () {
    if (Input.GetButton("Horizontal")||Input.GetButton("Vertical")) {
 
       var newForward : Vector3 = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")).normalized;
       if (newForward!=Vector3.zero) transform.forward = newForward;
 
       transform.Translate(Vector3.forward*Time.deltaTime);
    }
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox