playMaker

Author Topic: Put Schedule Scripts on Each NPC and Door, or in two "Processor FSMs?"  (Read 772 times)

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
okay, so these are two different concerns.

NPC's: there's a Time FSM that does a wait for 1 second, then updates the clock. Every 15 minutes, it send a process to a big "scheduler" fsm that iterates through all 1000 npcs in my game and sets a new navmesh agent destination on all of them, based on a SQL query from a tables managed by SimpleSQL.

Is it more efficient to do it this way, or would it be better to put a "schedule checker" fsm template on each NPC game object that runs this object  for each npc as needed (like if one NPC's hunger gets low, their own fsm can change their nav destination.)?

The second concern is things like doors, windows, and other set pieces. Currently I have a single FSM called "Door Manager". Any time a character or NPC interacts with a door game object, it sends that door go through this script and determines how to open it, if it's locked, etc. based on the names of children the door has. having a  "locked" child would prevent it from opening.

Is that efficient, or would it be better to have a "door" fsm on each relevant game object?

Does having a lot of scripts (4 thousand) that do nothing until triggered, create lag or anything? If I did that for each go, should those scripts be "deactivated" or something when not in use to save memory?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 the number of fsm running is really affecting perfs during instantiation, not during runtime. an fsm running or a regular script running is virtually the same.

I think your manager idea is good, but I am also ok with independant prefabs like doors that works on their own, it gives more flexibility overall than using a manager.

 It's really a matter of taste and how comfortable you feel with one or the other.

Keep track of perfs using the profiler, that's the main thing here, so that you can detect a drop in perfs than you can related to what you just did as opposed to works for days or weeks and then find out something is not done properly, then you are in more trouble than if you can address it right away.

 so profile often, that's key.

Bye,

 Jean