an ai script showing errors that make no sense java

I’m going from c# to java with scripts in a project I’m working on, but my code keeps coming up with errors that don’t make sense to me. can someone help me fix the issues with my code please? here is the code

var attackrange = 75;
var target:Transform;
var maxhealth = 25;
var currenthealth = 25;
var sightrange = 95;
var movespeed = 25;
var rotationspeed = 25;
var attackrepeattime = 2;
var giveUpThreshold = 95;
var chaseThreshold = 85;
var waypoint;
var currenttarget:Transform;

var mytransform:Transform;


function awake (){

	myTransform = transform;
}
function start (){

	target = GameObject.FindWithTag("RWaypoint").transform;
}
function Update (){

 transform.LookAt(target);
 
 
	if(GameObject.FindWithTag("Bplayer").target){
		mytransform.position += mytransform.forward * movespeed * Time.deltaTime;
		}
	if(GameObject.FindWithTag("BMinion").target){
		mytransform.position += mytransform.forward * movespeed * Time.deltaTime;
		}
	if(GameObject.FindWithTag("BBuilding").target){
		mytransform.position += mytransform.forward * movespeed * Time.deltaTime;
		}
	if(GameObject.FindWithTag("RWaypoint").target){
		mytransform.position += mytransform.forward * movespeed * Time.deltaTime;
		}
	
		if(GameObject.currenttarget.distance > sightrange){
			currenttarget.changetarget;
			}
				if((GameObject.currenttarget).currenthealth =< 0){
					changetarget = true;
			}
			
			else{
			
				if((GameObject.currenttarget).currenthealth > 0){
					changetarget = false;
			}
		}
		if((mytransform.currenthealth) = 0){
			death = true;
		}
	
}
function attack (){
	if((target.distance) =< attackrange){
		target.currenthealth - 25;
	}
}
function chase (){
	if((target.distance) =< giveUpThreshhold){
		currenttarget.changetarget;
	}
}
function changetarget(){
}
function death(){
}

You should show which errors you’re having! Anyway, at first sight there are several weird things in this script:

1- GameObject.FindWithTag(“…”).target: FindWithTag returns a GameObject reference, and the GameObject doesn’t have any target property, thus all lines like this will cause errors;

2- GameObject.currentTarget: currentTarget isn’t a GameObject property either, thus all lines using it will produce errors.

I suggest you to edit your question and post the original C# script, so that we can have a better idea about what’s going wrong.

my c# script is broken down into 3
seperet programs

’ using UnityEngine;

using System.Collections;



public class enemyair : MonoBehaviour {

	private Transform Target;

	public int movespeed;

	public int rotationspeed;

	public float maxdis;

	

	

	private Transform mytransform;

	

	void Awake() {

		mytransform = transform;

	}



	// Use this for initialization

	void Start () {

		GameObject go = GameObject.FindGameObjectWithTag("Bplayer");

		

		Target = go.transform;

		

		maxdis = Vector3.Distance(Target.transform.position, transform.position);

	

	}

	

	// Update is called once per frame

	void Update () {

		Debug.DrawLine(Target.position, mytransform.position, Color.red);

		              

		  //look at target

		mytransform.rotation = Quaternion.Slerp(mytransform.rotation, Quaternion.LookRotation(Target.position - mytransform.position), rotationspeed * Time.deltaTime);

			

		if(maxdis < 50){

			movespeed = 0;

			if(maxdis>50){

			     movespeed=25;

		

		}

	}

		

		if(Target=null){

			Target=Target.transform;}

		

		if(Vector3.Distance(Target.position, mytransform.position) > maxdis) {

		//move towars target

		mytransform.position += mytransform.forward * movespeed * Time.smoothDeltaTime;

		

	



	}

}

}'

for movement

’ using UnityEngine;

using System.Collections;



public class enemyattack : MonoBehaviour {

	public GameObject target;

	public float attacktimer;

    public float cooldown;



	// Use this for initialization

	void Start () {

		attacktimer = 0;

		cooldown = 2.0f;

	

	}

	

	// Update is called once per frame

	void Update () {

		if(attacktimer > 0)

			attacktimer -= Time.deltaTime;

		

		if(attacktimer < 0)

			attacktimer = 0;

		

		

	    if(attacktimer == 0) {

	    attack();

		attacktimer = cooldown;

		}

	if(target=null){

			target=GameObject.FindGameObjectWithTag("BMinion");

	}

	}

	private void attack() {

		float distance = Vector3.Distance(target.transform.position, transform.position);

		

		Vector3 dir =(target.transform.position - transform.position).normalized;

		

		float direction = Vector3.Dot(dir, transform.forward);

		

		Debug.Log(direction);

		

		Debug.Log(distance);

		

		if(distance < 50) {

			if(direction > 0) {

		       playerhealth eh = (playerhealth)target.GetComponent("playerhealth"); 

					eh.addjustcurrenthealth(-10);

				

			}

		}

	}

}'

for attack and

using UnityEngine;

using System.Collections;



public class enemyhealth : MonoBehaviour {

	public int maxhealth = 100;

	public int curhealth = 100;

	

	public float healthbarlength;

	

	// Use this for initialization

	void Start () {

	       healthbarlength = Screen.width /6;

	}

	

	// Update is called once per frame

	void Update () {

		addjustcurrenthealth(0);

	

	}

	

	void OnGUI() {

		GUI.Box(new Rect(20, 30, healthbarlength, 20), curhealth + "/" + maxhealth);

	}

	

	public void addjustcurrenthealth(int adj) {

		curhealth += adj;

		

		if(curhealth < 0)

			curhealth = 0;

		

		if(curhealth > maxhealth)

			curhealth = maxhealth;

		

		if(maxhealth < 1)

			maxhealth = 1;

		

		

	if(curhealth <= 0)

{

			

   Destroy(gameObject);

	

				

	

		

		healthbarlength = (Screen.width / 2) * (curhealth / (float)maxhealth);



}

	}

for health

The errors you mention in a comment on your original post are code errors, not runtime errors - it means you have at least one line of code typed incorrectly.

Reading over your code once, I found these.

if((GameObject.currenttarget).currenthealth =< 0){
              changetarget = true;
         }

You need to change =< to <=. Remember, less than < or equal to =, not equal to or less than.

if((mytransform.currenthealth) = 0){
         death = true;
       }

You need to change ‘=’ to ‘==’. One = is the assignment operator, used to assign the value on the right of the sign into the variable on the left side of the sign, while == is used to compare the values on either side.

if((target.distance) =< attackrange){
       target.currenthealth - 25;
    }

Another ‘=<’ to ‘<=’

if((target.distance) =< giveUpThreshhold){
       currenttarget.changetarget;
    }

And again. I would read up on your code syntax and order of operations, you have a lot of extra groups of parenthesis - that isn’t a problem, but by adding extras you’re just increasing the chances that you might leave one of them out and not be able to figure out where it is.