I converted this small script from JavaScript to C# and I cant seem to get the Transform.TransformDirection working. I get this error
A field initializer cannot reference the nonstatic field, method, or property `UnityEngine.Transform.TransformDirection(UnityEngine.Vector3)’
I have tried different variations as well as instantiating it before creating the vector but no go.
using UnityEngine;
using System.Collections;
public class characterController3D1 : MonoBehaviour {
public float speed = 6.0F;
public float jumpSpeed = 8.0F;
public float gravity = 20.0F;
public float slopeLimit = 45.0f;
public Vector3 vertical = Transform.TransformDirection(Vector3. forward);
public Vector3 horizontal = Transform.TransformDirection(Vector3.right);
public void movement() {
CharacterController controller = GetComponent<CharacterController>();
if(Input.GetAxis("Verticle") || Input.GetAxis("Horizontal")){
controller.Move ((vertical * (walkSpeed * Input.GetAxis ("Vertical"))) * Time.deltaTime);
controller.Move ((horizontal * (walkSpeed * Input.GetAxis ("Horizontal"))) * Time.deltaTime);
}
}
}