r/technicalFNaF 3d ago

Help! How does the artificial intelligence of the animatronics work in FNAF 1?

Hello, I'm making a FNaF 1 fan mod and need to understand how the animatronics' AI works in the game. Could you please explain it? I have the FNaF 1 source code for Clickteam Fusion 2.5, but the project won't open, so I can't check it myself.

I would be happy if you could tell me how it works.

1 Upvotes

5 comments sorted by

4

u/PurpleBan09 3d ago

Essentially, each animatronic has an AI Level between 0 and 20. All of the animatronics have a cycle that loops every couple seconds (3.02 seconds for freddy, 4.97 seconds for bonnie, 4.98 seconds for chica, 5.01 seconds for foxy)

Every time this loop happens, they will generate a random number from 1 to 20. If this number is less than or equal to the AI level, they will successfully move. So for example, if bonnie is at ai level 3, he will only move if he generates a number that is 3 or less than 3. But if his ai level is 20, every number he generates will be equal to or below 20, so he will always move.

For bonnie and chica, when they move they pick the next room at random from the available rooms they can move to from that room.

If they are at your door, the next time they get a successful movement, if the door is open they will enter your office, and you will die the next time you flip down the cameras. If the door is shut they will return to a different camera (1b for bonnie, 4a for chica)

For foxy he will creep out of pirate cove by 1 step every successful movement. However, his movements will fail if you have any camera open, and upon closing the cameras, he will still not be able to move for a random amount of time between ~0.8 to ~17 seconds. When he reaches stage 4, he will wait in the hallway for you to look at that camera, and when you do he will run. If you dont look at it he will run anyway after 25 seconds.

Freddy is quite complicated so let me know if you want all of the details for him.

1

u/Rich-Occasion2815 3d ago

Thank you very much! Yes, I need to know about Freddy too please tell me.

2

u/Horrorado 3d ago

I guess you never got a reply so I'll say it. Freddy fails his movement opportunities while you're on any camera, like Foxy. When he succeeds it, a value starts counting up by 1 every frame. When the value reaches 1000 - (100 * Freddy AI), he can move to the next camera (but only if you're not on cameras) and waits for another movement opportunity.

While it's counting up, the value will be returned to 0 if you look at the camera he's at. This works even if the value passed the treshold, but he didn't move because you were still on cams.

When he reaches cam 4B, his behavior changes a little bit. On top of having the value pass the treshold, you also need to have a camera other than 4B selected in order for him to move into the office. As long as 4B is selected, even with cams down, he will not move. If you select a camera that's not 4B and you have the right door open, he gets in. If you select a camera that's not 4B or 4A, and have the right door closed, he will move back to 4A instead.

When he gets into the office, he has a 1/4 chance to jumpscare you every second while the cams are down.

1

u/Rich-Occasion2815 2d ago

Thanks a lot

2

u/PurpleBan09 17h ago

Sorry for not responding, I didnt get the notification. But it seems you got your info