So i am writing a Ai script and my code seems to be ok (I am a beginner so i am not completely sure) and monodevelop dosen’t give me any error until the last line where I close my last void with ‘’}". Thanks for your help.
Here is the script:
using UnityEngine;
using System.Collections;
public class AiScript : MonoBehaviour {
private bool thisIsPlayer;
private GameObject objPlayer;
private GameObject objCamera;
private Vector3 inputRotation;
private Vector3 inputMovement;
public float moveSpeed = 100f;
private Vector3 tempVector;
private Vector3 tempVector2;
// Use this for initialization
void Start () {
objPlayer = (GameObject) GameObject.FindWithTag (“Player”);
objCamera = (GameObject) GameObject.FindWithTag (“MainCamera”);
if (gameObject.tag == “Player”) { thisIsPlayer = true; }
}
// Update is called once per frame
void Update () {
FindInput();
ProcessMovement();
if (thisIsPlayer == true)
{
HandleCamera();
}
}
void FindInput (){
if (thisIsPlayer == true)
{
FindPlayerInput();
} else {
FindAIinput();}
}
void FindPlayerInput (){
inputMovement = new Vector3( Input.GetAxis(“Horizontal”),0,Input.GetAxis(“Vertical”) );
tempVector2 = new Vector3(Screen.width * 0.5f,0,Screen.height * 0.5f);
tempVector = Input.mousePosition;
tempVector.z = tempVector.y;
tempVector.y = 0;
Debug.Log(tempVector);
inputRotation = tempVector - tempVector2;
}
void FindAiInput()
{
}
void ProcessMovement(){
rigidbody.AddForce (inputMovement.normalized * moveSpeed * Time.deltaTime);
transform.rotation = Quaternion.LookRotation(inputRotation);
transform.eulerAngles = new Vector3(0,transform.eulerAngles.y + 180,0);
transform.position = new Vector3(transform.position.x,0,transform.position.z);
}
void HandleCamera(){
objCamera.transform.position = new Vector3(transform.position.x,15,transform.position.z);
objCamera.transform.eulerAngles = new Vector3(90,0,0);
}