Questions about having a NPC move between scenes

  • #1, by TymorSaturday, 07. May 2016, 02:50 8 years ago
    I want a NPC to move between scenes when a certain condition is met. Nothing fancy, I just want the current scene to fade and the NPC to disappear to reappear in the next scene. Then when the player changes scene the NPC has switched locations. How can I set this up in the most efficient manner? Currently I have two objects set to the same condition (on appears only if the condition is false) and set two instances of the same character to each. However, the NPC appears in both locations despite the objects themselves being inactive.

    I hope this was understandable!

    Newbie

    26 Posts


  • #2, by afrlmeSaturday, 07. May 2016, 03:26 8 years ago
    I recommend using values instead of conditions as they are a lot more flexible than conditions, because values are potentially infinite & conditions only have 2 values, which are True or False.

    My suggestion would be to create a called by other action block (make sure you create it somewhere sensible & give it an appropriate name). Inside of this action block you have just created, add some if queries, something along the lines of...

    if value "npc_location" is 1
    if current scene is "name of scene for position 1"
    else
    execute a script > game.CurrentScene:to(200, {SceneBrightness = 0})
    pause 200ms
    set character "tom" to object (some object in another scene)
    pause 100ms
    execute a script > game.CurrentScene:to(200, {SceneBrightness = 100})
    pause 200ms
    end if
    quit current action
    end if
    if ...
    ...
    end if


    I guess you probably get the idea. Personally speaking this would be far easier to script with Lua than action parts, but if you don't know how to script then action parts it is. wink

    Long story short. Each time you changed the value you would then call the action block you created to see if the npc should be moved to another scene.

    P.S: why do you have duplicate npc characters? You only need to create one character per character as you can create multiple outfits for each character. Outfits are not actually outfits. They are basically different versions of your character.

    Imperator

    7278 Posts

  • #3, by sebastianSaturday, 07. May 2016, 11:29 8 years ago
    He did two because of two scenes i guess.

    I also have a question about how npc characters work here:


    Scenario:
    - 3 scenes
    - 1 npc stands at pos 1 in scene 1
    -Playable character stands at scene 2
    - Action areas on each exit if the map which only teleport the npc from scene 1 to 2, 2 to 3 and 3 to 1

    When i start a loop (lua or action part) which controls the npc moving globally. What happens exactly?


    Does the npc does his job, even if i am not in the same scene with the playable character?
    It should go to his exit and then hopefully appear on scene 2, right?
    Also it should then go to its defined places and then disappear on the next action area and reappear in scene 3 and so on. Also when i am moving with the playable character from scene to scene this should affect the npc loop...

    Am i theoretically right or do they only work inside the loaded scene?

    Thread Captain

    2346 Posts

  • #4, by afrlmeSaturday, 07. May 2016, 11:56 8 years ago
    No, loops can continue running in the background which why we (I) personally recommend you kill any loops you started inside of an at begin of scene action inside of an at end of scene action. The same goes for any sounds you started playing & infinitely looping too - well only if you don't need them to play in any other scene.

    As for whether the npc will actually do anything behind the scenes, I have no idea. It probably iterates through the actions, but whether or not it can actually interact with anything or whether it will just create errors / warnings in the log file because the scene & relevant data isn't shown, I have no idea (again) because I've not tested it.

    If you want to have it look like your npc has been doing random things then create a bunch of if queries at the begin of a scene along with some conditions / values that you randomly update to determine if the npc is already in the scene & if so where they should be positioned, what animation they should be playing, etc. You can run a loop in other scenes too to have the character appear in the scene you are in after a random amount of time, if the character is not already in the current scene.

    So basically 3 actions per scene for the npc. One to init the character & trigger the loop which you would call inside of an at begin of scene action. The second would be the loop. The third would be the at end of scene action in which you kill the loop.

    Imperator

    7278 Posts

  • #5, by MachtnixSaturday, 07. May 2016, 13:56 8 years ago
    What means "inside an at"?

    Thread Captain

    1097 Posts

  • #6, by sebastianSaturday, 07. May 2016, 14:05 8 years ago
    inside of an "at begin of scene action"

    Thread Captain

    2346 Posts

  • #7, by afrlmeSaturday, 07. May 2016, 14:08 8 years ago
    "at begin of scene" (Bei Beginn der Kulisse) & "at end of scene" (Bei Ende der Kulisse) actions.

    Sorry I forget that the editor is available in different languages.

    Imperator

    7278 Posts

  • #8, by MachtnixSaturday, 07. May 2016, 14:37 8 years ago
    Thx. I try to understand English, but often I didn't...
    I had the same problem a year ago, so I expect a better solution than my (I created the same NPC again for each scene, it wasn't very clever, but it works...).

    Thread Captain

    1097 Posts

  • #9, by sebastianSunday, 08. May 2016, 00:37 8 years ago
    As soon as i come to the point i need an npc which walks through some scenes i will try it out
    I hope this also helps Tymor smile

    Thread Captain

    2346 Posts

  • #10, by TymorSunday, 22. May 2016, 12:36 8 years ago
    This did indeed help a lot, thanks!

    Newbie

    26 Posts

  • #11, by irinahuw_Tuesday, 29. May 2018, 10:52 6 years ago
    Hello!

    I have the same/similar problem, but I do not understand the suggested solution.

    First question: Outfits & changing scenes

    Currently I set up 2 different persons for one NPC. One in scene 1, another in scene 2.
    I could not make it work with the outfits somehow, that's why i have 2 NPCs which are the same Character, but in different scenes. How can I make it work with the outfits only? I think using only one character with different outfits shown at different scenes would make more sense, but I could not place the NPC with a different Outfit in another scene.

    Second question: Values/Conditions

    I don't understand how and where I should set up the values/conditions for showing/hiding the character in the 2nd scene.

    What I want:
    The Maincharacter talks to the NPC in Scene1. The NPC then switches the scene from 1 to 2, but the scene itself for the Maincharacter & Player is not supposed to switch. After the Maincharacter enters scene 2, the NPC is waiting there and does something after talking to the Maincharacter. Then it returns to Scene 1 again.

    What I have:
    The Maincharacter talks to the NPC. In the Dialogue i set up an Action, so that after talking to the NPC, the NPC walks out of the scene and disappears (send character to position, hide character). After this, I would like the NPC to appear in the 2nd scene. But currently it is always there, no matter if the Maincharacter talked to the NPC or not. Also I did not manage to make the NPC return from scene 2 to 1. When all the actions are done and Scene 1 is entered, the NPC keeps walking away & disappearing.

    It's very confusing...I'd be very happy about inputs & suggestions!

    Irina

    Newbie

    49 Posts