ApericotStudio / Poltergeist

Main repository for development of the Poltergeist game
0 stars 0 forks source link

Fix: NPC not following room structure (IMPORTANT) #373

Closed ThijsvanDijk closed 9 months ago

ThijsvanDijk commented 9 months ago

Ask Lucas for more clarification

UpperCi commented 9 months ago

Visitor roams the expected amount of time in the first room. After that, it will 'choose' a new room every 5 seconds, regardless of what it's currently doing. This even leads to them skipping rooms if they have to walk a long distance.

UpperCi commented 9 months ago

Maybe found the problem? In NPC/States/RoamState.cs, the Handle() function calls PeriodicallySwitchRoomCoroutine(). This function contains asynchronously switches rooms. Could it be that this gets called whenever the visitor changes state, e.g. by looking at a new object?

KiwiLT commented 9 months ago

Dani hit the nail on the head with his theory. A switchroom coroutine was started each time the npc went to roam state, which equals each time they look at an object.