I'm looking for a way to have NPCs have default movements, something simple like walking around. I've given them an autoplay event on the prefab which works fine. The only problem is when I interact with them they keep walking. Ideally I would like them to stop and face the character interacting with them until the interaction is over and then resume their movements between waypoints. I've been looking around for solutions to this within the framework and wondered if anyone could point me in the right direction?

Any help would be appreciated. Thanks!
  • I wrote up a tutorial on how to do this with a click-to-move style of control: http://forum.orkframework.com/discussion/2910/tutorial-pc-rpg-style-mouse-driven-interactions-baldur-s-gate-fallout-etc/p1

    Not sure what sort of control scheme you're using, but the approach should adapt well enough to a more direct control scheme (just leave out the loop where it waits for the player to reach the destination). The NPC interaction is on the second page of what I linked to but it builds on the first example. If you are using click-to-move, don't use the custom event steps DLL file that I linked to because it was compiled against an older version of ORK.

    Using this approach, I had NPCs wandering using Move AI (with idles) and when I click on one to interact with, he would stop moving, turn to face the player, and wait for the interaction to end before resuming movement.
  • Thanks for the reply! Maybe I am missing something but are you making every NPCa combatant to apply a move AI to? Basically I can't figure out how to apply a move AI to a normal NPC.
  • Yes, I have a Combatant component on every NPC. "Character" would perhaps be a more appropriate name than "Combatant" as this is also where you define animation and movement settings, as well as where you can assign a icon and portraits.

    Setting up NPCs as combatants lets you define their stats, so even if they don't engage in combat, you have something to "roll against" if the player uses dialogue skills or spells on them.

    I also find it nicer to work with characters in an Event through the Combatant event steps, rather than just treating them as objects.
  • Awesome that worked, thanks. I am noticing an issue however that each time I interact with the npc it will switch to the next way point instead of continuing to the way point it was previously on. I'm defining several way points for the move ai with a simple move event that moves them to each way point. Have you run into this sort of issue ? Also I'm wondering how to fire different events at different way points. Like animations or wait a certain amount of time.
  • edited April 2016
    I didn't get as far as defining specific waypoints for the NPCs yet. I just have them wandering around and performing various idle animations. So I can't help you with skipping the waypoint they were on before the interaction.

    You could try adding a trigger box to each of your waypoint GameObjects and an Event Interaction with start type set to Trigger Enter. In the attached game events, instead of setting the Player as one of the actors, set it to Starting Object.

    With this setup, I think that any character walking into the trigger will start the event, so you'd need to add some conditions, either in the Event Interaction component on the waypoint, or at the beginning of the Event attached to it. The simplest way might be to have it check for an Object scoped bool variable such as useWaypoint10. You can make this a condition on the Event Interaction component (make sure you check "Check object variables"), and then add Object Variable components to each NPC who you want to be able to use that waypoint (you can also add those variables in the Combatant and/or Scene Object settings in the editor as well).

    I *think* that should work, but I haven't tried it yet. @gamingislove, does this sound right to you?
    Post edited by Keldryn on
  • Thanks so much for all the replies. Something interesting I just came across is that if I'm using waypoints for moving an NPC around, using the block ai steps work perfectly. However if I am using just a value of xyz or any other object as the target for moving the NPC the block ai step doesn't work and the NPC keeps on walking. I figured this sort of functionality would be pretty standard - having an NPC move around and do different things while still being interactable at any time.
  • You're welcome!

    When you say you're using a value of xyz or an object as the target for NPC movement, do you mean in a Game Event or Move Event?

    Block Move AI does exactly that: it blocks any movement started by the Move AI settings. If you are setting destinations via Events or scripts, they won't automatically be blocked as well.

    I believe that you can check if Move AI is blocked using an Event step, so you could place checks in your Event to not proceed with movement if Move AI is currently blocked.

    You could also add a component to all of your NPCs that checks to see if Move AI is blocked in its Update() method. If it is blocked, then you can have it call NavMeshAgent.Stop() (if that's what you're using), disable the character controller component, etc.

    You'd want to make it more robust so that you can still have characters move via an event step but not through the Move AI, but that's a start.
  • Yeah I mean a move event attached to the npc via the move ai. Just changing the move event from using a waypoint to the same xyz value of that way point makes block ai not work
Sign In or Register to comment.