Forum rules - please read before posting.

Player drawing a weapon and holding it?

I've got a player character I want to be able to draw a weapon and hold it. Now I could find a bunch of unity tutorials for this, but I wasn't sure how well those would play with AC or indeed if AC could do something already similar.

Should I add a parameter to the Player script, under Mecanim parameters (similar to "Talk bool", "Jump bool", something like "Gun drawn bool" or "Sword drawn bool"?) Because I assume I'd want to add some animation function via my Animation Controller.

Or should I look in to creating a whole new script, basically following standard Unity procedures? I've got my weapons as children of the character GameObject, one in a holster and the other as if it were being held in the player's hand, thinking that I'd set one to visible and the other invisible when the time was right, but I'm not sure if that's the typical way of doing it.

Thanks for anyone who could give advice, apologies if this isn't the right place to be asking this.

Comments

  • Welcome to the community, @Daveyploo.

    AC doesn't have combat or weapon features, but just the act of physically placing something in the player's hand shouldn't be too problematic.

    The 3D Demo has the Player hold the "prop sword" item for a couple of sequences. As these are isolated sequences (where the player stops holding the sword afterward), this is done by parenting it to the Player's hand via the Character: Hold object Action.

    It's also possible to do it entirely through animation, however, and having "holdable" items as invisible child objects on the Player is a valid method. This is how Unity animate their player character wearing glasses in their own adventure tutorial. This is covered in AC's recreation of this tutorial here.

    With smart use of sub-layers to handle what the player is holding, I'd imagine you could do this without having to resort to a custom script. Any parameters that you add to the Animator Controller can have their values changed at runtime using the Character: Animate Action, and these values can be stored in save game files by attaching the Remember Animator component to it.

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.