generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Broken AI script needs help.

Previous Thread :: Next Thread 
superior is not online. 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 is not online. 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 is not online. 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 is not online. 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
DealerNextDoor is not online. DealerNextDoor
Joined: 20 Feb 2011
Total Posts: 32
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 is not online. 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
DealerNextDoor is not online. DealerNextDoor
Joined: 20 Feb 2011
Total Posts: 32
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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image