- Home /
I'm trying to make AI that walks (and faces) towards a waypoint
could someone please show me the code im new to unity/coding and making a school assessment
Answer by greatestprez · Dec 04, 2012 at 03:30 AM
try something like this:
public Transform waypoint;
public int speed;
void Update() {
transform.LookAt(waypoint);
transform.position = Vector3.lerp(transform.position, waypoint.position, Time.deltaTime * speed)
}
thank you much appreciated however it appears with a compiler error Assets/Bison Behaviour.js(17,8): BCE0043: Unexpected token: Transform. Assets/Bison Behaviour.js(18,8): BCE0043: Unexpected token: int.
and am i to replace my code for yours or just add it one then end/start?
sorry im a noob :( thanks for your time!
That error is most likely there because i am using c# and you are using Javascript, a version written in javascript would look something like this: (sorry if there are any syntax errors, javascript isn't the language i usually use)
var waypoint : Transform;
var speed : int;
function Update() {
// the rest should be the same as the c# script
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Trying to make AI travel (and face) a waypoint 0 Answers
Controlling AI Movement 0 Answers
AI movement bug ("teleporting" after certain Platforms) 0 Answers