# Translate and Rotate

#### -

How to use the two transform functions Translate and Rotate to effect a non-rigidbody object's position and rotation.

## Translate and Rotate

Anfänger Scripting

### Code snippet

``````using UnityEngine;
using System.Collections;

public class TransformFunctions : MonoBehaviour
{
public float moveSpeed = 10f;
public float turnSpeed = 50f;

void 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);
}
}``````
``````#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);
}``````
``````import UnityEngine
import System.Collections

public class TransformFunctions(MonoBehaviour):

public moveSpeed as single = 10.0F

public turnSpeed as single = 50.0F

private def 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))``````