Forum rules - please read before posting.

Spawning NPC and Interactions

I need some tips on how to do this properly. I have a game that keeps day of the month, day of the week and time of day. NPC's spawn at certian times of the day and week.

Is it possible to be able to spawn an NPC and assign an interaction on the fly?

When I spawn my NPC in the scene the interaction type is empty. I'd like to be able to change the convo when a character is spawned.

How would i go about doing that?

Comments

  • Set the NPC's Hotspot's Interaction source field to Asset File - you can then assign ActionList Assets, instead of scene-based Interaction objects, for each of their interactions. That way, these can be set in prefabs and will be retained when spawned in the scene.

  • What if I want it to be a different interaction file. Like a different convo on a different day.

  • If the day is stored in a Global Variable, you can use the Variable: Check or Variable: Popup switch (if a PopUp) Actions at the start of the ActionList to then run a different ActionList depending on what day it is.

    Of course, you can also modify the Hotspot's interactions through script:

    myHotspot.useButtons[0].interaction = myNewInteraction;

  • It's stored in a global variable. I use both playmaker and ac variables to monitor the variables.

    What is a variable popup switch

    i'll do some playing around with it and post results.
    Thanks.

  • What is a variable popup switch

    It's an Action that lets you run different Actions according to a PopUp variable's value.

  • Ok I need some help. I am able to spawn an NPC on any day now. However I cant assign any interaction on a specific day.

    I set the interaction source to asset file. In the scene when i spawn my character, how do i choose what interaction file to set. there's no action for that.

    If i set an interaction asset file that has run action list action, is that where I put the check variable in?

  • I also need some advice on the best way to do this.

    So the game im making right now takes place over 2 months. I have a time manager that manages the day month and time in the day.

    Each day, i want to have an event that happens which can be a conversation or a quest. I also have quests and events that trigger on certain days.

    I have a total of 7 scenes which the game takes place in.

    Right now, how im doing it is dividing the events by days in each scene. I have a gameobject divided by days in scene 1 and on Monday day 1, an event will play in scene 1. That same day, in scene 2 another event will play but i have to create a new gameobject like i did in scene 1.

    Can I carry the gameobject from scene to scene for day 1 that keeps updating or something.

    I was thinking, is that the best way to do it?

    It could get hectic and confusing if i have over 100 events in scene 1 over 50 days in the game.

    Should I create multiple scenes for scene 1 and divide them by days but that might not work in case I update a scene geometry.

  • I set the interaction source to asset file. In the scene when i spawn my character, how do i choose what interaction file to set. there's no action for that.

    There's no Action for that because it's recommended to instead enable/disable Interactions or use variables within the ActionLists. What Interaction is assigned isn't saved by the Remember Hotspot component, so if this is changed then this won't be reflected in save games.

    A custom Action can be written to change a Hotspot's Interaction field - see the code line above - but I still recommend going down the variable route.

    If i set an interaction asset file that has run action list action, is that where I put the check variable in?

    If you have the Hotspot run an ActionList asset, then that asset's first Action should be the variable-checking Action. Based on that Action's output, you can then run a different ActionList accordingly.

    Since you are using variables that can only be discrete values (e.g. "Day of the week" can only be "Monday", "Tuesday" etc, then I would recommend having these be of the type Pop Up. This way, you can make use of the Variable: Pop Up switch Action to react to all possible values the variable might have in one Action - rather than having to chain together multiple instances of the Variable: Check Action to go through all of the different possible outcomes.

    Can I carry the gameobject from scene to scene for day 1 that keeps updating or something.

    What is this GameObject, exactly? An item the player can pick up? Something interactive e.g. a Hotspot? For a mechanic so complex, you'll need to elaborate more for me to fully understand your situation.

  • edited September 2019

    The game object is an empty game object. Because I have multiple events in each scene, I have to organise them using empty gameobjects into days and months.

    I also need some advice on the best way to do this.

    **So the game im making right now takes place over 2 months. I have a time manager that manages the day month and time in the day.

    Each day, i want to have an event that happens which can be a conversation or a quest. I also want to have quests and events that trigger on certain days. Like on Monday and Thursday, there will be an NPC hanging out in a particular place.

    I have a total of 7 scenes which the game takes place in.

    Right now, how im doing it is dividing and organizing the events by days in each scene. I have an empty gameobject(Maybe a game manager) which im using to organise the events into days and months. For example, in scene 1 which is the first scene, it is Monday day 1, an event will play in scene 1. That same day, in scene 2 another event will play.

    Because that game manager is in scene 1, I also have to create a new game manager in scene 2.

    Is there a way to carry the gameobject(Game manager) from scene 1 to any other scene in the game. I know unity has **don't destroy on load **which carries objects from scene to scene.

    Its a little bit complicated.

    Would a game manager that has all the events work? If so how do I do events in Scene 2 if the game manager starts in scene 1?

    Is it better for every scene to just have their own set of events.

    It could get hectic and confusing if i have over 100 events in scene 1 over 50 days in the game.

    Should I create multiple scenes for scene 1 and divide them by days but that might not work in case I update a scene geometry.

    Thats why i was asking if it was possible to spawn NPC's and convo and interactions, even cutscenes. That was I just spawn the right cutscene on the right day and right time.
    **

  • I don't understand why you'd be spawning an empty gameobject, but I'm assuming that your "Game Manager" carries a custom script or something.

    Yes, using Unity's DontDestroyOnLoad command is how to make a GameObject survive scene changes. But we're getting away from AC here.

    When it comes to spawning AC objects - be mindful that you can't spawn scene-based ActionLists (cutscenes, interactions) for the same reason that you can't turn them into prefabs. Any ActionList that you want to keep out of a scene file must be an ActionList asset file, but Conversations, Hotspots, Triggers etc can all rely on asset files for their Actions.

    A scene-based ActionList can be converted to an asset file via its Inspector's cog menu. I'd recommend using asset files when related to anything you want to "spawn" in.

    However, be aware that you can always prefab your scene geometry. If you decided to go down the route of splitting a location into multiple scenes (one for each day, for example), then you could rely on the same prefab for your graphics / NavMesh so that changes are still felt by all.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.