Forum rules - please read before posting.

How to create a bobbing animation for a sphere character?

Hello AC Community!

I'd love to hear your thoughts and suggestions on something that's been driving me crazy for the past two days. I have a player character that's just a sphere—no limbs, no head, so basically a toddler should be able to animate that. I really only want it to do two things: a little bobbing while idle and a faster bobbing when walking. But here's what happens:

1) I have a player prefab with all the scripts and an animator attached to it. It's set to Mecanim and the Rig of the model is Generic.
2) I create a parent object for this prefab, so the bobbing is relative to its position rather than absolute coordinates.
3) I create a bobbing animation with just the Y values changing and delete the X and Z keyframes.
4) In the Animator, I create two states, Idle and Walk. I assign the bobbing animation to both states with different speed values.
5) I set the conditions for the transitions between Idle and Walk to Speed > 0.1 and Speed < 0.1.
6) I run the game, and after the cutscene, the character teleports to the 0, 0, 0 coordinates, moves up and down on the spot, and doesn't move from there.

Funnily enough, if I create a new animator and place it on the model inside the prefab, it bobs up and down and moves, but the bobbing speed stays the same. I'm seriously mind-boggled. I hope I explained it clearly!

Thanks in advance for your help!

Video of the issue

Animator

The bobbing animation keyframes

Player settings

Comments

  • edited June 2024

    Make sure that Has Exit Time is unchecked in your transitions, and that Loop is unchecked in the Animation Clip inspectors.

    If it still has the issue afterwards, share a longer video with the Animator open while it occurs.

  • edited June 2024

    Thanks for your comment, Chris! I unchecked the Has Exit Time box as well as the looping, and now he's not moving at all. Here's a longer video of the situation:

    Bobbing issue

    The only way it kinda works is if I attach the animator to the model and not the player prefab, but it has no way of knowing the speed has changed...

    Bobbing issue 2

    I feel like the animated object has to have a parent so that the animation coordinates are relative to the parent's position, but when the player is spawned at Player Start, it's obviously always parent-free...

  • and that Loop is unchecked in the Animation Clip inspectors.

    Apologies - that should have been Loop is checked.

    now he's not moving at all

    Is it possible that's an issue with the scene's NavMesh? Unless the Animator is affecting the root position, it shouldn't interfere with pathfinding.

    The only way it kinda works is if I attach the animator to the model and not the player prefab, but it has no way of knowing the speed has changed...

    The Animator can be on either the root, or the child, but not both. AC can work with an Animator on the child object, but if you have one on the root as well, then that's the one AC will manipulate.

    You can force exactly which one AC affects by assigning the "Animator (optional)" field in the Player's Inspector.

  • I see! I had an intuition that having two Animators on one character won't be ideal. :#

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.