Forum rules - please read before posting.

Active Input for Wearable Inventory Asset...

I am making a 3D direct Game.
Sorry i did not Add any screen shot while i thought It is absurd in my case .... or i can not see which part could be important technically to show...

Here i explain...
To be summerized it is one inventory asset that is wearable. I want player to take it On/Off by pressing a key.
here i go explaining :smile:

  • In one scene the Player picks up an Inventory Asset (a Hat or a cage) which using active Input Key "o", it can be Toggled On or Off his head.
  • I defined Active input key and Assigned an Action list Asset file (as I learned through the AC Manual)
  • So whenever the hat is On players head, The inventory Asset is Removed then "HatON" Mecanim Play Custom will be played. It uses the HatAnimatorController. i also use a Global Variable for "when The hat is ON" (HatOn). so that with the second push of O button it can check if Hat is On of We have no Hat Inventory asset....

  • When the Key is pressed for the second time>If Globar Variable HatOn
    -is true> The HatOff Animation will be played and Hat adds to inventory again
    -Else(of false) > It check if Inventory Availability > if Available it puts the HatON / Else It says: "We got No hat"

  • it works fine in the Same scene i made it.

  • But when the player goes to other scenes (Scene Switch) , The Active input Key only adds or removed Inventory Asset Hat to Inventory box . but on player's Head ( in the scene) , we see no change.

I treid to Check Global Variables for other scenes on the Onstart Action list... But it seems just messing up...

How i can use This input key all around the game So that when ever the User pushes the Key "O" , the hat apears on players hat and with second press of O button it disapears?

thanks in advance

Comments

  • Screenshots are always helpful - in this case, images of your ActionList asset, and the Player's Animator / Inspector will help understand the situation.

    When an ActionList asset file references scene objects, it does so by recording a "Constant ID" value - this is used to relink the asset and the scene object together after the scene is closed and re-opened.

    You'll need to make sure that this ID number - which should be listed in your Actions - matches that on the Player.

    Is your Player object a prefab that is spawned into your scenes automatically, or do you have a Player GameObject present in the scene files themselves?

    If you relied on an instance of the Player in the scene, the Constant ID would have been assigned to that Player only. If the Player is a prefab, check that the Constant ID component is there also, and that Retain in prefab? is checked so that this ID is consistent throughout the game.

    A pair of tutorials that cover the use of Constant ID values to link assets and scene objects can be found here.

  • thanks. for all scenes i do not spawn Player prefab into the scene and i just use the AC normal setting which has the Player placed in scene. but for this scene (thescene) when the HAt/Cage is picked up, i spawned the Player prefab into the scene and exactly there i started to add the Hat as a child of Player's Spine.
    So just to test i droped the player perfab in the next scene too. but it makes complications.... I go watch Constant ID related tutorials to learn and in the same time i will gather some screenshots + a video record of the work i do... hopefuly i can provide them all in couple of hours.
    Thanks again

  • edited May 2023

    Hi ...
    What i understood from the great tutorial is that i must only check retain in prefab!
    Or maybe i restart my work from the scratch and creat Actionlist asset again not inside the scene but in my Prefab file...
    I avoided doing so, just to wait and see what would be your feedback and insights on this Screen recording...
    As you see When i press "o" in second and third Scenes ... It only add/removes the Hat/cage to inventory and nothing happens to the Player inside the secene.+ THe player does not continue to apear in second and third scene according to its last condition...
    In the Second scene i did it using variable check.... but i am not sure if i did the right thing.
    In the third scene i used no variables ...

    Here is Video
    https://rumble.com/v2og7li-constant-id-cagehat-active-input-complexity.html

  • Because Retain in prefab? is unchecked, the Remember Animator component will generate a new Constant ID value each time it is placed in the scene.

    You will need to check this option in the prefab shown at the start of your video.

    Doing so won't necessarily generate the same number as assigned in your ActionLists, however. After checking this option, set the Set field to Manual, and set the ID to 225928 (the ID as it was assigned in your Actions).

  • Wow , thank you . It is fixed ... THannnnnnnk you.

  • Oppps , just a small bit of a question again...
    When the scene changes The Player shows up as it normaly is without the Hat. How can i make it so that when the scene changes the Player keeps showing up how it was in the previous scene?
    If he had the hat ... then apears with hat in next scene.
    If he was notmal... then apears normal in next scene.
    sorry to be the dumbest in the Forum :?

  • If you place your Player manually inside a scene file, its state will be treated independently from other scenes.

    You will need to allow AC to spawn the Player automatically, so that it is persistent across your scenes.

  • OOO... Right i forgot to remove player from second scene. Thanks Alot Chris.
    You are obviously Amazing

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.