Forum rules - please read before posting.

Issue With logic | Global Variable | Inventory Item | Failing to trigger hot spots

Bit of a complicated issue I am having. Was wondering if somebody could help please.

I will start with what I am trying to do. When the player has a key item, a shovel in the inventory, 2 hot spots appear in the front garden ( hot spot teleport ). You can drag the item on these hot spots and take the final item. A bone! This worked initially.

Originally this worked when all the logic / code was placed 'on start' - It appeared to work. But in placing it "onstart" it was when the big issues came later on. The code would fire on start... and only 'on start'. It appeared to work. But. When it came to testing this outside of the Unity it came unraveled. The on-start logic would not recognise the code when the player came back into the scene (NOT) from the start of the game, if that makes sense. I also tried onload to no avail.

I then tried :- OnVarChange and again. Noting appears to be working outside placing it on start. I'm happy to scrap this method altogether if somebody has a better suggestion of where to place this bit of global script. I'm happy to listen.

In nutshell, I just want those hotpsots to work when the player has the shovel - and only when - the player has the shovel.

I started to try to remedy this before Christmas but have really struggled.

Any help is welcome. Thanks AC community. - And a happy new year.

Comments

  • What's your AC version? OnStart should kick in whenever entering a scene through natural gameplay.

    A caveat: if you're using Player-switching, then OnLoad will be called instead when switching to a Player that's already inside that scene.

    We'll first need to determine if the issue truly is that the Cutscene isn't running, or if it's a case of the Actions not having the correct effect.

    An alternative to the Scene Manager's "Cutscene on start" field is to attach the ActionList Starter component to the Cutscene, and configure its Inspector. Try using this instead.

    At the start of this Cutscene, insert something that can be used to easily identify it as running - a Dialogue: Play speech Action, for example - then look out for it to tell if it's running at the correct time or not.

  • Good question, this is something that I would need to check with the versions. It does semi-work - but only when I start from that part of the game. It doesn't fire once the global var has been changed the scene 3. ( this is all going on in scene 1 ) In other words, when I come to doing a full run and beta test of the game, It fails.

    Interesting what you say about the cutscene not running or whether its something I have missed / tied myself in knots about with the cut scene.

    Will have to have a look here "An alternative to the Scene Manager's "Cutscene on start" field is to attach the ActionList Starter component to the Cutscene, and configure its Inspector. Try using this instead." and see who I can do this. Something I hope I can look at, at the end of the week.

    "At the start of this Cutscene, insert something that can be used to easily identify it as running - a Dialogue: Play speech Action, for example - then look out for it to tell if it's running at the correct time or not."

    • Yes, thank you. I have been using this method as a makeshift ( trace / debug ). FYI, the text didn't appear.

    Thanks,

  • What is your AC version, and how are you switching to the scene during gameplay? Via the Scene: Switch Action?

  • Just checked. my AC is version 2021.2.5f1. It's a slightly older version. Would that still cause the logic to only partially work?

    I'm using **Scene: Switch **.

    Thanks Chris,

  • Should also be noted that I have just tested the OnStart and this fires the code. And displays a line of dialogue. J

  • edited January 2023

    Just checked. my AC is version 2021.2.5f1.

    That's your Unity version - the AC version can be found at the bottom of the AC Game Editor window.

    Should also be noted that I have just tested the OnStart and this fires the code.

    Is that to say the OnStart cutscene is working after all?

  • Whoops. My mistake. My AC is version 1.75.5.

    Yes, it is odd and I'm guessing that it's not that the onstart isn't firing. A line of dialogue is Now working. It should be noted that I deleted most of the code in the on start. I might try to rebuild parts of it piecemeal and see what it does.

  • Hello Chris, before I wrap up for Friday I wanted to get my old thinking cap on while it is still fresh in my mind.

    I have more or less scrapped the original way I created this logic in the game. And I have come to the conclusion that the onStart is working! But I want to go with the alternative suggestion you recommended: ActionList Starter

    Purely from a theoretical perspective, what would be the best approach here? I have a variable that says "if you have x tool" - move the interactive hotspots to these arrows. ( Teleport ) in scene one. when the player drags the shovel onto these. The player can dig ( reveals a hole when dug, this bit of code works )

    if possible,I would like to make this a global thing. so when the player owns the tool, I might add a bit of dialogue or tracer dialogue that says " today feels like a good day to dig" in other words. When that variable | boolean is true those 2 interactive areas come live from another scene. if that make sense? ( and that bit of dialogue fires )

    Thanks Chris. Any pointers on the best approach? ( Aside from on start )

  • You don't necessarily need to rely on a variable to achieve this - if the only factor is the presence of a particular item in the player's Inventory.

    The Inventory: Check Action can be used to check if a partuclar item is currently present in their Inventory. If you follow this Action's If condition it met output socket with an Object: Teleport Action, you can have the Hotspot move into position if the Player is carrying the specified tool.

    When these Actions are run will depend on when you want this teleporting to take place.

    If it's enough to simply move the Hotspot into position as the scene begins, you can use OnStart / ActionList Starter. While they're functionally very similar, the key difference between the two is that ActionList Starter allows the ActionList's logic to be self-container - i.e. no need to assign it in the Scene Manager. This makes it much easier to work with should you want to work with prefabs / parameters, which would allow you to use this logic anywhere in your game.

    ActionList parameters are a complex tool, and you may want to get the above working first before looking into them, but a basic tutorial can be found here, while a more advanced video covering practical examples can be found here.

  • Hello Chris, tremendously helpful thank you. I managed to get it working, taking much of what you said into account - inventory checking. What I was finding for some reason was that the 2 parts of the logic weren't working onScene start.

    so..,

    I used the run parallel and appears to have done the trick! on the face of it. should be noted that this was also placed right at the start of the logic / code for anybody reading.

    And thank you for letting me know about the self-contained ActionList. Too true that I think as this is my first mini project, I should leave this to more advanced steps. Perhaps for another project.

    Have a good weekend!

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.