- Home /
Path Nodes are not working
Hi, Can anyone help me, basically i want to create nodes like in Call of Duty Radiant ( Mod Tools) in which NPC's can follow, i have no errors in my code but the NPC does not do anything when i start.
Code:
var Next : Transform;
var Character : GameObject;
private var CanWalk = true;
var Speed = 5.0f;
function Update ()
{
if(Next.active == true)
{
CanWalk = true;
}
if(Next.active == false)
{
CanWalk = false;
}
}
function OnTriggerEnter (other : Collider) {
if(other.collider == Character){
Character.transform.LookAt(Next);
Character.rigidbody.AddForce(transform.forward * Speed);
}
}
Answer by SkyreGames · May 09, 2013 at 04:44 PM
var Next : Transform;
var Character : GameObject;
private var CanWalk = true;
var Speed = 5.0f;
function Update () {
Character.transform.LookAt(Next);
if(Next.active == true) {
CanWalk = true;
}
if(Next.active == false) {
CanWalk = false;
}
}
Now it works but it only looks at players position. You used the OnTriggerEnter and that means the function will only work when you touch the colider. I just changed the OTE to Update. I think it doesnt do its job but this is kinda usefull :3
Your answer
Follow this Question
Related Questions
How can I make companion npcs follow the player's path, ala Chrono Trigger? 2 Answers
Making a forked path with iTween 1 Answer
How to create a path of nodes? 1 Answer
Go back to first node (itween + moveto) 2 Answers
Get current node in itween path 0 Answers