convert C# script to java

can anyone convert this script in to a java one

using UnityEngine;

using System.Collections;

public class AutoAI : MonoBehaviour { public float speed = 20; public float rotatespeed = 10; public float dis = 1; public float LeftRight = 2; public float infront = 1; private int direction = 60;

// Use this for initialization
void Start () {


// Update is called once per frame
void Update () {

            if(!Physics.Raycast(transform.position, transform.forward, infront)){
        transform.Translate(Vector3.forward * speed * Time.deltaTime);
        if(!Physics.Raycast(transform.position, -transform.right, LeftRight)){
            direction = 1;
        else if(!Physics.Raycast(transform.position, transform.right, LeftRight)){
            direction = -1;
        transform.Rotate(Vector3.up, 60 * rotatespeed * Time.deltaTime * direction);



The 'code' formatting feature doesn't seem to work correctly all the time, but if you post code and find that it hasn't been formatted correctly, please edit your post and try to fix it (assuming you haven't already).

As for your request, Java (not 'java') isn't supported in Unity; what you're most likely referring to is UnityScript (aka 'javascript', although it still isn't 'real' javascript), which is a different language entirely.

What I'd recommend is that you attempt the conversion yourself, and then post here or to the forums with specific questions if you run into problems.

I don't use UnityScript so I can't guarantee correctness here, but here's a few tips to get you started:

  • Remove the 'using' statements and the class declaration.
  • Replace variable declarations of the forum 'public [type] [name] = [initial value]' with 'var [name] : [type] = [initial value]'.
  • Replace '[return type] [function name]()' with 'function [function name]()'.

Obviously there's a lot more to it than that, but that should at least get you started on porting the script you posted above.