Forum rules - please read before posting.

Tire Swing character animation/interaction advice/help needed

Hi all, I'm pretty new here, this is only my second post. I am working on this adventure game in my spare time. I am having some issues as to how best to set up this character swinging in a tire swing and would really appreciate some advice on what to do. I have created a video for visual representation of what I am about to explain.

Right now I have a hotspot where you can get on the tire swing. Then I have an Interaction list that can play animations based on if a button is pressed. Right now I have it set so that if the -> right arrow key is pressed he will swing higher and ^ up arrow key goes back slower and eventually out of the tire swing.

The states of animation are basically:
1 Getting in tire
2 Idle in tire
3 Swing Low in tire
4 Swing High in tire
5 Getting out of tire

I have created transition animations that go to and from 2, 3, and 4 (as seen in video)

This may not be the best way to set this up, but my main issue right now is that I want to create a Parameter in Mecanim where it will allow me to blend when I come out of say Swinging High into > Swinging High to Low transition. I need to have a parameter such as a Bool or Float?? that enables it to blend. Right now it just pops from Swinging High into my Swinging High to low transition as you see in the video (you'll notice it happen around 1:00 in the video).

I have tried a few things like adding to my current action list to set a bool to true or false but that doesn't seem to work very well so I took it off. If I could map a Parameter to the button pressing so it knows when to blend to my transition I think that would work, maybe(I don't know how to do that)? Without a Parameter to tell it when to blend it will just go in and out of Swing High and not loop, thus the need for a way so it knowns when to transition.

If anyone has any suggestion or advice I would greatly appreciate it.  I will include my video link and image of how I have my action list set up. Thanks!



http://s1.postimg.org/554abewjz/Oscar_Swing_Action_List.jpg

Comments

  • The ActionList you've posted looks to be quite a lot more compex than it ought to be.  You ought to be able to re-wire it so that you've only got one Input: Check Action of each button type (Horizontal / Vertical etc).

    Secondly, you don't want to re-run Actions unless you have to.  Action 4: Input Check should loop back on itself if the condition isn't met: the Mecanim FSM should be set up so that the Idle animations don't need to be re-run.

    The general answer to your problem is to use Trigger parameters.  A Trigger parameter will be "on" for one-frame only, and so is easier to manager than bools or ints.

    When working with a complex Mecanim FSM like this, it's advised to rely solely on parameters, rather than calling animations specifically.

    As an example (and you'll have to go over Unity's official docs/tuts for the specifics) create a Trigger parameter in your Mecanim window called e.g. IdleToLow.  Adjust your Mecanim window so that the transition from IdleInTyre to SwingFromIdleToLow is conditional upon this parameter.

    Next, change Action 7 (Character: Animate) so that the Method is set to Change Parameter Value.  Enter the name of your parameter and set the Parameter type to Trigger.  That means that you'll now have full control over the way the two animations blend.
  • edited February 2015
    Hi Chris, thanks so much for your feedback! That really helped me out a lot, you have no idea! I figured that Acton List I made was pretty broken too haha. Your Action List Node Editor is a powerful asset to have with AC! I culled out everything as much as I could and used Trigger parameters in Mecanim (great suggestion btw) I then just needed to use three triggers to play through the swinging animation states. 

    So now that I got everything working much better now, the only thing I can't seem to figure out is how to get him to start in the exact same place so he lines up each time. I am using the walk to Marker/ face after moving and even have a face object with another marker set up to get him in the right place/rotation. This works perfectly if he comes in from the right side, but for some reason when he comes in from the left he doesn't line up with the tire animation. (I'll include video link so you can see what I mean)

    So basically my question is whether there is a way to specify exactly where he will start each time once he walks to the marker? After much trial, error, and research, I can't seem to find an easy solution.  Thanks again for your help. This will be most beneficial as I have lots of custom animation I would like to use for different types of interactions so this will keep me busy for a while.

     Also on a side note in my video near the end around 1:15 you will notice my character, when I press to turn (I'm using direct control) He turns and then does a little step forward even if I just tap the arrow key? It's like an extra pause then step for some reason. I don't have turn animations plugged in yet so maybe that is why, but thought I would ask?  (edit: * This part was caused by my moveSpeed conditions in Mecanim being set too low 0.01 instead of 0.1, solved now)

    I will include my updated video and Action List for anyone interested. Hopefully this will help anyone else out that is doing custom interaction type animation stuff. Thanks!



    http://s21.postimg.org/s0z7v2r1j/Oscar_Swing_Action_List_Updated.jpg
  • Hey there!

    Pathfinding is not exact, so when walking to the hotspot's maker the character will not stop exactly at it. If I remember correctly :P I would have to check the code to see if the last point of your path is taken err "more seriously" than the in-betweens, Chris will tell you better. If that is the case, your character stops near the marker, but not exactly there, by a margin configurable with "destination accuracy" at the scene manager.

    I did something like this, in 2D, where a custom anim needed a exact starting point... I'll have to check it at home... but maybe I did a Object: Teleport to the marker (copying rotation) in my actionlist to be sure the sprite were at right place.
  • Hi MaaS, nice to meet you! Thanks for taking the time to comment, I really appreciate it! I just got home and checked what you were mentioning and it does appear that I can do an Object Teleport on the character. I didn't even realize that would work on a character, but that seems to do the trick. 

    A little bit of snapping into position is not a huge issue, but I also noticed there is an Object Transform Action too, which allows me to dial in some transition time to lessen the quick snapping/popping into place.  This will work great for what I need to do with a lot of my animations. Thank you for pointing me in the right direction!
  • edited February 2015
    Yep, Object Transform should work also... I used it for moving from right to left some background clouds and loop :P

    Although I wish it were a bit more configurable: transforming position, rotation and/or scale, from origin to target, or by X increment in an axis, or look at object, or follow object...

    @ChrisIceBox About pathfinding... shouldn't it be something like (bad pseudocode)?:

    characterPosition += calculatedIncrementPosition;
    if (characterPosition.distance(targetPosition) < destinationAccuracy )
    { characterPosition=targetPosition; }

    The same for rotation.

    Or something like that... I haven't seen the code in a while, and I've changed things here and there (as I have my own pathfinding and use float to int positions to ensure pixel perfect movement) but at least for the last point of your path, shouldnt it finish exactly at your target position?...
  • @shawneclark: Glad I could help.  Yes, the Object: Transform Action would be of use here - be aware that you can also supply a Marker point to transform to, rather than entering the exact co-ordinates.

    @MaaS: I like the suggestion, but it would cause a "snapping" effect if the destination accuracy setting is too low.  I'll think about 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.