Ok so I am fairly new to unity/c# and I was trying to follow a youtube tutorial and I keep getting errors that i have been trying to fix for the past few hours.
using UnityEngine;
using System.Collections;
public class EnemyAI05 : MonoBehaviour {
public float moveForce = 0f;
private Rigidbody rbody;
public Vector3 moveDir;
public LayerMask whatIsWall;
public float maxDistFromWall = 0f;
// Use this for initialization
void Start () {
rbody = GetComponent();
moveDir = ChooseDirection (); <— ERROR HERE
Transform.rotation = Quaternion.LookRotation(moveDir);
}
// Update is called once per frame
void Update () {
Rbody.velocity = moveDir * MoveForce;
if(Physics.Raycast (Transform.position, Transform.forward, maxDistFromWall, whatIsWall))
{
moveDir = chooseDirection();
Transform.rotation = Quaternion.LookRotation(moveDir);
}
Vector3 ChooseDirection() AND another error in the first parentheses.
{
System.Random Ran = new System.Random();
int i = Ran.Next(0, 3);
Vector3 temp = new Vector3 ();
if (i == 0) {
temp = Transform.forward;
}
else if (i == 1)
{
temp = -Transform.forward;
}
else if (i == 2)
{
temp = -Transform.right;
}
else if (i == 3)
{
temp = -Transform.right;
}
return temp
Sorry if there is another way to post my code. it is my first time using the forums
2847547–207968–EnemyAI05.cs (1.07 KB)