Hi,
I have recently started to use Unity, and since I’m not a C# expert, I had some problems.
I want to make a car go from behind a building to another building, and loop that so when the car reaches the building, it teleports to the original building to do the same path again and again…
The problem is that I don’t know how to express ‘When it reaches X position’ without getting an error. The error happens at line 13.
Also, I noticed I can’t put Space.World in Transform.Traslate (it says * isn’t a valid operator for Vector3 and Space). Why?
CODE:
using UnityEngine;
using System.Collections;
public class FixedPath : MonoBehaviour {
private Transform transform;
void Start() {
}
// Update is called once per frame
void Update () {
if(transform.forward = -32) {
transform.Translate(Vector3.forward * Time.deltaTime);
}
else {
transform.forward = -27;
}
}
}
I’m sorry for being a noob, i know it’s boring to answer stupid questions.
Thanks!