Forum rules - please read before posting.

Toggling clothing visibility within a player prefab with player switching enabled

Hey Chris,

Hope everything's great with you! I'm diving deep into a project using Adventure Creator v1.79.3 within Unity 2022.3.0, and it's been an incredible journey so far. Your tool has been a game-changer for me, especially as I navigate through the complexities of game development without a strong programming background.

Initially, my game was set up in single character mode. I had a nice little system going where my character could switch outfits by toggling the visibility of different clothing items, all skinned directly to the character mesh for that seamless look. This setup was not only perfect for my workflow, allowing for easy customisation and adding a lot of depth to the character's personalisation, but it also utilised a method of toggling object visibility to maintain fewer character prefabs. This approach neatly simplified my project's structure by reducing the need for multiple prefabs for different outfit combinations.

Recently, I've decided to enhance the game's interactive experience by shifting to multiple character mode, enabling players to switch between characters. This move aims to introduce more dynamics and player choice into the game. However, I've run into a snag with replicating the clothing customisation system I so loved in single character mode. I want to ensure that each character has their unique set of clothing options that are skinned to them, maintaining that personalised touch. The challenge is to keep these customisations distinct and independent when players switch characters, mirroring the streamlined efficiency and simplicity we achieved with the object visibility method in single character mode.

Given that my experience with scripting is quite limited, I'm reaching out to see if Adventure Creator offers a straightforward way to manage this transition. Is there a feature or a recommended approach that allows for the same ease and functionality of clothing customisation in multiple character mode, akin to what I had in single character mode?

I'm hoping for a solution that's manageable on my end and seamless for the players, enhancing their experience without complicating the development process unnecessarily.

Thank you so much for your time, and for creating Adventure Creator. It's been an essential tool in bringing my game to life, and I'm excited to see how I can continue to evolve my project with your guidance.

Warm regards,

Raff

Comments

  • Welcome to the community, @RAFF.

    Is the main issue that of the UI, as each character would have their own options? I think I'll need details on how you're achieving that for the single-character. If any custom scripts are involved, share those as well.

    So far as how costumes are handles goes, I'd recommend the use of animation to control what's worn and what's hidden.

    Basically, each "costume type" would be its own sub-layer in your Player's Animator, with each costume choice being its own animation within that layer, transitioned to with an Integer parameter. For example, the Hat layer would show "None" if Hat=0, "Cap" if Hat=1, etc. Each animation would set the correct Hat object's visibility to True, and all that of all other Hats to False.

    Changing a costume choice is then just a case of updating its respective Integer parameter value.

    This could be done with the Object: Animate Action, but you could also attach a Variables component to your Player, make new Integer or PopUp variables for each Animator parameter, and then use the Link Variable To Animator component to link them. This would let you use the Variable: Set etc Actions to control them instead.

  • Thanks for the quick response, Chris!


    Apologies if my first post was confusing.
    No custom scripts were used In my single-character setup. I’m a non programmer so I’ve been finding solutions without any coding but I can implement code..

    The main issue wasn't the UI but the method of hiding and revealing clothes connected individual characters.

    My initial solution worked for my single player version but I couldn’t get visibility to toggle the same way on costume objects in the player swap enabled version.

    I managed costume changes directly through Adventure Creator's ActionLists by toggling the visibility of clothing items skinned to my character. I also incorporated a simple UI button in the inventory, with an on/off toggle that adjusted a specific variable. This variable wasn't just for the costume changes but was also intended to influence how other characters in the game react to the player's current outfit.

    Your suggestion, moving to an animation-based system using Unity's Animator for costume management sounds like a promising approach. However, I'm trying to wrap my head around how to transition from my current method to the one you've described. I would never have thought of the layer solution it sounds more controllable though..
    Best regards,

    Raff
  • The other advantage of this technique is that you can condense the data-saving aspect into a single component - Remember Animator (or Remember Variables, if you're linking the parameters to variables). This'll allow the costume changes to be restored when loading a save - and also when switching Player character, if your game supports mid-game switching.

    I'd recommend testing the technique out in a separate character (or even project) first, to get a feel for the approach.

    Start with just a single layer and costume piece (e.g. a hat), and then create two animations - one that hides the hat mesh, another that shows it. Add them to a sub-layer and use a "Hat" integer parameter to control which gets played.

    At runtime, you can keep the Animator window open and adjust the Hat parameter value manually - without needing to use Actions - to test that it has has the correct effect.

    If you give it a try and would like an extra set of eyes on things, share details/screens and I'll look things over.

  • Hi Chris,

    I hope you're doing well. Thanks so much for your help with this. I tried something new with a test character one layer. I added glasses that can be shown or hidden with animation, and it worked great!.

    I ran into a problem when I added a camera that moves around (an orbit camera). For some reason, the glasses don't show or hide correctly when this camera is in the scene. It seems like the moving camera is causing some issues with how the glasses appear or disappear.

    I was wondering if you have any ideas on how to fix this. Making sure everything works right with the moving third person camera.

    Thanks again for all your help. Your advice has been really useful

    Best,

    Raff

  • This may be a Unity issue than one specific to AC.

    If an object's visibility is affected by camera orientation, check the mesh's bounding box - as Unity can hide meshes automatically if it detects the box is out of view.

    Check also that the Animator's Culling mode is set to Always Animate.

  • If it’s Unity I hope they fix it soon .. I’ll double check if Always on is being used..





    Thanks Chris

    Best,

    Raff
  • Sorry, to clarify: if it's what I'm suspecting, it's not a bug, just the behaviour.

    Check the option, but another way I find helps to determine if this is the cause is to keep the Scene window open and focused on the mesh. Does the mesh then stay visible in both the Scene and Game windows at all times?

  • Hi Chris,

    Following your advice, I checked the Animator's Culling Mode and ensured it was set to "Always Animate". I also kept an eye on the mesh through the Scene window to observe its behaviour in both the Scene and Game windows they both showed the same behaviour, as you suggested. Despite these adjustments, the issue persists unchanged.

    Interestingly, I've noticed that sometimes when the camera collides with other objects in the scene the visibility toggling of the skinned mesh animations functions correctly for that moment.

    Thanks,

    Raff
  • To be clear: the mesh also hides in the Scene window?

    What's the exact type of Renderer you're dealing with? If it's a Skinned Mesh Renderer, try checking Update When Offscreen in its Inspector.

    Otherwise, keep the live Animator window open at the time, and check that the correct animation is playing continuously. Also select the mesh in the Hierarchy, and check that the Renderer component you're controlling through the animation is consistently enabled.

  • Correct. the mesh also hides in the scene window when it hides in the game window ..
  • edited March 11

    I'm using the Skinned Mesh Renderer. I have enabled Update When Offscreen

  • And that had no effect?

    What were the results of checking the live Animator and Inspector windows at the time the mesh becomes hidden?

  • No effect
  • The Animator in your video isn't "live" - you need to select the object in the Hierarchy for it to show which animation is playing at runtime.

    It does look like your project has more than AC present. I can't tell from the video if another asset may be contributing, but I don't expect the issue is from AC directly.

    If you'd like to PM me a .zip of your project, with instructions on how to recreate the issue, I will take a look.

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.