TAPTAPTAPTAP
7/25/2013 - 1:48 PM

Rotace a translace po zmáčknutí tlačítek UNITY javascript

Rotace a translace po zmáčknutí tlačítek UNITY javascript #unity3d

#pragma strict

public var moveSpeed : float = 10f;
public var turnSpeed : float = 50f;


function Update ()
{
    if(Input.GetKey(KeyCode.UpArrow))
        transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
    
    if(Input.GetKey(KeyCode.DownArrow))
        transform.Translate(-Vector3.forward * moveSpeed * Time.deltaTime);
    
    if(Input.GetKey(KeyCode.LeftArrow))
        transform.Rotate(Vector3.up, -turnSpeed * Time.deltaTime);
    
    if(Input.GetKey(KeyCode.RightArrow))
        transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime);
}