Question by
Seyed_Morteza_Kamaly · Dec 07, 2015 at 01:56 PM ·
unity5java to c#
How can i have var in c#
var forward = transform.TransformDirection(Vector3.forward);
var input = Input.GetAxis("Vertical");
function Update(){
transform.position += forward * input * Time.deltaTime;
transform.Rotate( 0 , Input.GetAxis("Horizontal") * 45 * Time.deltaTime , 0 );
}
I want conver javascript to c# but i have some errors:
using UnityEngine;
using System.Collections;
public class TransformDirectionx : MonoBehaviour {
float forward = transform.TransformDirection(Vector3.forward);
float input = Input.GetAxis("Vertical");
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.position += forward * input * Time.deltaTime;
transform.Rotate( 0 , Input.GetAxis("Horizontal") * 45 * Time.deltaTime , 0 );
}
}
2015-12-06-23-47-56.png
(15.5 kB)
Comment
"... but i have some errors:"
we'd be able to help more if you included the errors (including line numbers). it's probably line 15, but not a good idea to guess...
Start with
Vector3 forward = ...
ins$$anonymous$$d of float
Your answer
![](https://koobas.hobune.stream/wayback/20220612051644im_/https://answers.unity.com/themes/thub/images/avi.jpg)