Forum rules - please read before posting.

New Scene on examining item?

Hi!
I was wondering the best way to go about my "problem". I want the player to be able to examine items in the game which will then trigger a closeup of the item for further inspection. Looking for hotspots etc. One example is examining a newspaper and then being able to look through it and look for ads and articles. The best solution must be a scene right? I looked at Documents too but it doesn't seem like that is the correct route.
Thanks for any input!

Comments

  • You could use Button elements inside a custom Menu to add simple interactivity, but for proper interactions you'll be best off using Hotspots etc as normal.

    The simplest way would be to switch to a new scene, yes, but you could also create a prefab out of the whole close-up and spawn it into the scene when the item is examined.

    You can use the Object: Add or remove Action to spawn prefabs in at runtime, and you can position it relative to the camera so that it always appears in front of it.

    The main thing to be aware of is that Actions cannot be included in prefabs - you'd have to set your Hotspots' Interaction source fields to Asset File and have them refer to ActionList assets instead. A tutorial on prefabbing game logic can be found here.

    Again, though, if you're looking for simplicity then a new scene is certainly a viable option.

  • edited July 2020

    Or perhaps do it as a menu? Ah just saw your response! Thanks

  • Yes I got into a little bit of an issue with the scenes anyway since it's tedious to keep track on which scene I was in before opening the newspaper. The newspaper consists of several scenes so the switch previous only works if we dont open the newspaper.

    I made a solution that works but I want the player to remain in the same place as berofe opening the newspaper. A custom script that saves information about current scene and position of player could work but reading your comment the Object solution seems like the better option. Will give that a try. Thanks!

  • For completeness: if you did want to go down the scene-switching route and have the Player return to their original position, you could rely on AC's player-switching system.

    By this, I mean you could create an invisible Player that's only present in the close-up scenes. When you want to run a close-up, you could switch that Player to that scene (Player: Teleport inactive Action), then switch to them (Player: Switch) instead of switching the scene. Then, when you're ready to exit the close up, just switch back to your "main" Player.

  • Aha okay. Yes well Object sounded a lot simpler since we don't have to keep track in which "game scene" we are currently in.

    BUT how do I make the Object cover the game scene? Preferrably it should cover the whole camera and

  • To be clear: switching player would mean you don't have to keep track of the player's original scene, since AC will automatically open up the scene the player is located in.

    how do I make the Object cover the game scene? Preferrably it should cover the whole camera and

    Is this for a 2D or a 3D game?

    It'd be easier for a 2D game, since the camera is then typically always facing the same direction.

    Actually, you should be able to also include a GameCamera as part of the prefab, and position that camera so that it's looking over the prefab's interactive objects.

    Just note that in order to reference objects on prefabs, you'll need to attach a "Constant ID" component to such an object and make sure that Retain in prefab? is checked on it. That way, the object will always have the same ID number no matter what scene it's spawned in. A pair of tutorials on this topic can be found here.

  • Ah yes that true! Didn't think of that. That clarified it a lot. Both methods should work. It's a 2d game.

  • edited July 2020

    Aaah, just realised there was a part two as well. Will look into that too then.

    Somehow I can't switch to a GameCamera connected to a prefab even if the camera has a constant id. The ActionList cant find it in the asset list and if I manually drag and drop it into the slot it disappears on start. What am I missing? I followed the link you referenced.

  • Is there an instance of the camera prefab itself in the scene? You can assign a prefab in an Action, but it'll still refer to the scene instance via its Constant ID.

  • Still having issues with this.

    The issue with the object add and remove approach is that I have an actionlist running in the background of one scene that. I tried moving all the affected objects and turned them into prefabs with constant id:s

    Then I tried the player swapping and scene approach. Works halfway but I cant figure out how to swap back to the main player and come back to the scene I was in before opening the newspaper (swapping to newspaper scene 1 there are a total of four scenes so switch previous scene wont always work) swapped to the "FirstPersonView" player.

    I could do a global variable I guess to keep track on this but it seems tedious too.

  • OK so I've sort of gotten it to work now. But it won't remeber the position in the scene when I switch back to the main character. Any help? I've tried replacing the player and using appear in new scene.

  • Update: Got it to work now, we can close this thread :smile:

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.