superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 21 Jan 2012 03:24 PM |
posi = script.Parent.Torso local target = nil while true do wait(0.1) if (findNearestTorso(posi.Position).Position - posi.Position).magnitude < (findNearestNode(posi.Position).Position - posi.Position).magnitude then target = findNearestTorso(posi.Position) if (findNearestNode(posi.Position).Position - posi.Position).magnitude < (findNearestTorso(posi.Position).Position - posi.Position).magnitude then target = findNearestNode(posi.Position) if target ~= nil then print(target.Name) script.Parent.Zombie:MoveTo(target.Position,game.Workspace.Base) end end end end
If the Node is closer to the AI Bot than the nearest Torso, The AI Bot will follow the Node, as coded to do so.
But when the Nearest Torso is closer to the AI Bot, the Bot walks in a straight line for a few seconds then stops, until the Node is closer than the Nearest Torso again.
What it's supposed to do is follow the closest object, whether it be a Torso or a Node.
Sorry if I'm confusing.
~When life gives you lemons, you sell them and make a profit~ |
|
|
| Report Abuse |
|
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 21 Jan 2012 03:39 PM |
I needs halp please.
~When life gives you lemons, you sell them and make a profit~ |
|
|
| Report Abuse |
|
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 21 Jan 2012 03:58 PM |
...
~When life gives you lemons, you sell them and make a profit~ |
|
|
| Report Abuse |
|
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 21 Jan 2012 04:10 PM |
Can someone just tell me why it doesn't work? I'll figure the rest out on my own...
~When life gives you lemons, you sell them and make a profit~ |
|
|
| Report Abuse |
|
|
|
| 21 Jan 2012 04:23 PM |
According to the title, your script needs help, not you. So you should ask it what's wrong.
posi = script.Parent.Torso local target = nil while true do wait(0.1) print("Executed code chunk") if (findNearestTorso(posi.Position).Position - posi.Position).magnitude < (findNearestNode(posi.Position).Position - posi.Position).magnitude then print("Player is closer") target = findNearestTorso(posi.Position) if (findNearestNode(posi.Position).Position - posi.Position).magnitude < (findNearestTorso(posi.Position).Position - posi.Position).magnitude then target = findNearestNode(posi.Position) print("Node is closer") if target ~= nil then print(target.Name) script.Parent.Zombie:MoveTo(target.Position,game.Workspace.Base) else print("Target is nil") end else print("Player is closer. (I think?)") end else print("Node is closer") end end
Try using this and see what it prints. This is usually what I do to find out what's wrong.
TheNewScripter |
|
|
| Report Abuse |
|
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 21 Jan 2012 04:28 PM |
I didn't even realize that... -_-
Now it's printing which is closer, but it's not moving to the Target. Thanks for clearing it up though. :D
~When life gives you lemons, you sell them and make a profit~ |
|
|
| Report Abuse |
|
|
|
| 21 Jan 2012 04:31 PM |
Still need help with some stuff? I didn't bother reading any of it, just put the prints.
TheNewScripter's ALT |
|
|
| Report Abuse |
|
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 21 Jan 2012 04:38 PM |
I just edited it a little. The same thing is happening. Once the node is farther from the Bot than the nearest Torso is, the bot just stops, until the node is closer to the Bot than the nearest Torso is... I don't know why?
~When life gives you lemons, you sell them and make a profit~ |
|
|
| Report Abuse |
|
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 22 Jan 2012 01:33 PM |
I hate bumping, but I need an answer.
~When life gives you lemons, you sell them and make a profit~ |
|
|
| Report Abuse |
|
|