x


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);
        }


}
more ▼

asked Dec 14 '11 at 07:54 PM

joeybubble1 gravatar image

joeybubble1
55 14 19 30

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
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

more ▼

answered May 09 at 04:44 PM

SkyreGames gravatar image

SkyreGames
3 1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x238
x71
x19
x8

asked: Dec 14 '11 at 07:54 PM

Seen: 533 times

Last Updated: May 09 at 04:44 PM