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 » Scripters
Home Search
 

Re: AI Visibility Tutorial

Previous Thread :: Next Thread 
kellymoose is not online. kellymoose
Joined: 13 Sep 2016
Total Posts: 1027
17 Apr 2017 01:51 AM
Here's a tutorial on how to see if a part in Workspace is visible to an A## ### not going to write the actual script, so just use this guide and script it yourself.

1) Have the character and the head defined.
Keep in mind that hats can block the view, so this might not work on AIs with shades, masks, or any hats covering the front of the head. If this happens, define the hat instead of the head, so it checks based from the hat.

2) Check if there's nothing in the way between the head and the part using a raycast. Raycasts are rays cast from a start point to an end point. They only stop at either the target, the range maximum, or if something gets in the way.

If the hit is the part targetted, then there is nothing in the way.

3) Check if its the field of view. It sounded complicated at first, but there's a simple way to do it. First, define the CFrame 4 studs in front of the head. Then, define the CFrame 4 studs in front the pointer CFrame, which is the CFrame that is positioned at the head, but facing the target. Then, check if the magnitude between the points is less than 5.

The way this works is that there will be two locations creating an angle. The first point of the angle is 4 studs in front of the head, and the second point is 4 studs from the head towards the target. If the magnitude is more than 5, then the angle created by the parts is too big. If the magnitude is less than 5, then the angle is small enough, and is indeed visible to the head. You can always change 5 to something else, if its not accurate.

4) Return the value. If there is nothing in the way AND its in the right angle, then the part IS visible, otherwise, its not.


Report Abuse
kellymoose is not online. kellymoose
Joined: 13 Sep 2016
Total Posts: 1027
29 Apr 2017 05:33 AM
b


Report Abuse
Rice_Nice is not online. Rice_Nice
Joined: 12 Mar 2017
Total Posts: 166
29 Apr 2017 06:00 AM
Interesting that you check the length between the two vectors. Typically you would dot the two to find the angle between them, but I suppose it's not that much different.
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
29 Apr 2017 07:22 AM
rice are you an alt


Report Abuse
Rice_Nice is not online. Rice_Nice
Joined: 12 Mar 2017
Total Posts: 166
29 Apr 2017 07:48 AM
Yessir. I don't use my '09 anymore.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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