playMaker

Author Topic: Link animation to object movement  (Read 2208 times)

MP

  • Playmaker Newbie
  • *
  • Posts: 10
    • View Profile
Link animation to object movement
« on: November 16, 2012, 10:49:20 PM »
What's the best way to link an animation (say, a walk cycle) to an object's movement. I want the animation to play only while the object's transform is moving. I want a different animation to play once the object is no longer moving.

I'm sure this is covered somewhere, and I'm just not finding it. Thanks.

MrMitch

  • Full Member
  • ***
  • Posts: 131
    • View Profile
    • Rage Quit Games - Coming Soon
Re: Link animation to object movement
« Reply #1 on: November 17, 2012, 04:18:57 AM »
I managed to get this working very simply.

In my game the character moves left and right with A and D, all i did was set it up so that when one of these keys were pushed the appropriate animation would play. So when you push a key, movement and the animation work at the same time from the same key.

I hope this makes some sense to you, if not i can post up some pictures

MP

  • Playmaker Newbie
  • *
  • Posts: 10
    • View Profile
Re: Link animation to enemey AI movement
« Reply #2 on: November 17, 2012, 08:59:23 AM »
Ah, yes. I understand well how to check if the player's character is moving. I mean a non-user controlled character, for example, an enemy AI.

While the enemy AI is advancing toward the player, his walking animation should play. When he reaches a certain point and stops, his walking animation should also stop and transition to a standing pose.

I should have worded the Subject line of my question more clearly. Thanks, though, for your reply.

MrMitch

  • Full Member
  • ***
  • Posts: 131
    • View Profile
    • Rage Quit Games - Coming Soon
Re: Link animation to object movement
« Reply #3 on: November 17, 2012, 09:18:12 AM »
Ahh ok, the only thing i can think of is putting a Play Animation action in the same state as the movement action but it depends on how things are set up, how are you moving the enemy?

MP

  • Playmaker Newbie
  • *
  • Posts: 10
    • View Profile
Re: Link animation to object movement
« Reply #4 on: November 17, 2012, 11:57:35 AM »
Two ways: some of the enemy AI's are moved along an iTween path. The others I'm moving via FSM MoveToward, setting the player as the target.

I could have the animation play in the same state as the MoveToward, but what happens if the player quits moving and the enemy AI arrives at the player's location (plus the programmed offset)? In that case, the enemy AI is still playing the walk animation, for example, even as he doesn't go anywhere. That looks strange, doesn't it?

MrMitch

  • Full Member
  • ***
  • Posts: 131
    • View Profile
    • Rage Quit Games - Coming Soon
Re: Link animation to object movement
« Reply #5 on: November 20, 2012, 09:52:10 AM »
If you could post up some pictures of your setup or make it into a package and i'll see what i can figure out as i'm not understanding your setup.

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 111
    • View Profile
Re: Link animation to object movement
« Reply #6 on: November 21, 2012, 06:54:45 AM »
What I did, whether the character is moved by user input or AI, is this: In the state you're moving, you do the translate (whichever way you prefer), and send an event to another FSM which controls the animations for the current character. This approach might require 2 FSMs in a character, but your movement is less coupled to the animation.
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer: http://www.youtube.com/watch?v=yxfkGy4N-lQ

Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8