NPC AI Script

Hi, ive never scripted before, and with a game i’d like to make, i need a simple script that i can apply to NPC PreFabs. But i dont know how. Does anyone have a simple script with variables that i can change and work with for enemy NPC’s? :stuck_out_tongue:

You’ll need to provide a lot more information. Can the NPC move? Does he need to know how to avoid static objects, moving objects, find the fastest route to somewhere, find the longest route to somewhere? I mean I’ve really only touched on path finding there, and then you could move onto decision making, using behavior trees, finite state machines, etc.

I don’t mean to sound like I’m trying to put you off, but asking for an AI script is like asking for an ice cream. Theres a lot of different types of ice cream, and not specifying the type could land you in a sticky situation…I apologise for that last pun, but seriously, a little more info would be helpful.

Well, i haven’t really made anything yet; i still need to learn Cinema 4D to make, animate, and put in all the characters, and i really dont know were to start, but the NPC AI script will probably be the most complex.
When i make the character, I’ll give the info. What will i need really?

Can I recommend trying some tutorials, such as some modeling an animating tutorials in the modeling package of your choice (Cinema 4D I assume). Then try some of the Unity scripting tutorials.

You’re really jumping in the deep end, and I can almost guarantee it will put you off making games. I’ve seen a lot of people start off with grand ideas and lose interest very quickly because they are trying to achieve something that takes a long time. I’d also recommend trying out the different disciplines, art, programming, design, etc. and then decide to follow one. It’s far too much work to try and learn all of them, and spreading your skills so wide will make you a jack of all trades, master of none.

In regards to your question, “What will I need really?”, that boils down to what kind of game you’re making. AI can be as simple as walking from one point to another than back again, or it can be incredible squad based tactical systems that have multiple AI entities working together. Work out what you want to make before you try to make it. You will save a lot of time by doing a bit of planning.

hi i also have problems with a npc script but i know what i want i want like a zombie like script he needs to follow my character and try to destroy it he needs to avoid walls and stuff and if my bullet with tag “bullet” hits it it must be destroyt

the most basic form of a script like that would be to make the npc always turn towards the player and then move forward. usually the physics system should take care of the rest :wink:

Ok i already had the npc look at me but i can’t it to move and do the ohter tings i want oh and btw i can shoot it so forget about that

Wow, thats cool. AI Really doesn’t have to be that hard, but mu last one had like 40 variables, most booleans, but the one from the FPS tutorials only has like 10. How would I cut down on this?