Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

So instead of dishing out 150$ for SpriteManager 2 (Unity Package), I've been playing around with Orthello which a free SpriteManager package.

I got most of everything I'd like working and it was fairly easy to setup however I am running into a few issues:

General 2D Question
1. How does one go about moving the gameObject with an animation?
I have an animation of a monkey that I'd like to play as I jump from Vine to vine. The animation plays on the spot (as I was instructed they should all do). However now I'm running into problems on ways in which I should move my transform according with the animation playing?
Should I lerp on the update thread? Lerp on every frame event?

Specific To Orthello

  1. I've setup my animations on the animation container and assigned 'Duration' values. The problem is that the animation will finish playing once the Duration has passed without playing every frame of the animation. Is this normal behaviour for animation systems? I imagine it's doing this in order to compensate for how often it gets updated.


If people would like I can post my C# Script. Here is a youtube video of so what I have also if anyone is curious.
here is a blog post I made on the subject as well (include the video)

share|improve this question
1  
Those two questions are separate topics and as such should be separate questions. –  Tetrad Sep 29 '11 at 19:10
    
Well if no one answers, I'll try and split it into two :) –  Setheron Sep 29 '11 at 19:42
1  
@Setheron please separate the questions, it's far more helpful to the community when at large when it comes to searching. –  Noctrine Sep 30 '11 at 4:58
add comment

2 Answers

up vote 1 down vote accepted

Yeah just move your character in the update method when you press forward, you can make your animations reactive to the movement or your reactive to the buttons, you'll have to decide yourself.

something like this perhaps? To add to my script you can also put in more checks to see if you are playing already with animation.IsPlaying("") so you don't call animations when you don't need to..

void Update ()
{
    Vector3 moveDirection = Vector3.zero;
    if (Input.GetKeyDown(KeyCode.LeftArrow))
    {
        moveDirection = new Vector3(1, 0, 0);
    }
    if (Input.GetKeyDown(KeyCode.RightArrow))
    {
        moveDirection += new Vector3(-1, 0, 0);
    }
    if (Input.GetKeyDown(KeyCode.Space))
    {
        // jump
        moveDirection += new Vector3(0, 1, 0);
    }

    if (moveDirection.y > 1)
    {
        animation.Play("JumpAnim");
    }
    else
    {
        // wait for jump animation to stop
    }

    if (moveDirection.x > 0)
    {
        animation.Play("LeftAnim");
    }
    else if (moveDirection.x < 0)
    {
        animation.Play("RightAnim");
    }
    else
    {
        animation.Stop("LeftAnim");
        animation.Stop("RightAnim");
    }
    transform.Translate(moveDirection * Time.deltaTime);
}

To answer some of your blog post questions.. Should animations with movement still be animated in the center (i.e. on the spot)? Yes, if you created a walk cycle for you character you don't move the characters position in the animation, you do this in code.

How do you take care of moving the sprite during the animation? Lerp the position? Use Transform.Translate method

How do you tie in the movement distance/time it takes to get there with the number of frames in the animation? You get properties like length, time, and speed from your animation like so

animation["JumpAnim"]

Please reference these links when developing with Unity

http://unity3d.com/support/documentation/ScriptReference

http://www.unifycommunity.com/wiki/index.php?title=Tutorials

http://www.unifycommunity.com/wiki/index.php?title=Scripts

http://www.unifycommunity.com/wiki/index.php?title=Tips

this deals with 2d movement http://unity3d.com/support/resources/tutorials/3d-platform-game

sprite stuff http://www.unifycommunity.com/wiki/index.php?title=SpriteManager http://www.anbsoft.com/middleware/sm2/

Here's a custom search tool created with google search for unity related stuff http://www.google.com/cse?cx=002470491425767499270:iugs1ezlsfq&ie=UTF-8&tbs=qdr:y&q=unity%20search

Unity has a well established community full of examples of this kind of stuff.

share|improve this answer
    
I meant was what if I wanted my animation to include movement (almost like a cinematic). I was unclear about how about to go set that up. –  Setheron Sep 30 '11 at 14:08
    
Right, so just create your animations and any movement you want controlled in game should be coded –  Jacob S Griffith Sep 30 '11 at 15:11
add comment

On Orthello,

An OTAnimation object can have multiple named animation framesets, each of those named framesets can be given a duration.

When you OTAnimatingSprite.Play a named frameset, this duration is used and all the framesets's frames are displayed in exact the duration of the named frameset.

You can OTAnimatingSprite.PlayLoop to keep it looping.

When you play the entire animation (so all framesets) the OTAnimation.duration or fps is used to determine how fast all frames have to be played.

Orthello does not stop an animation or named animation frameset before all frames have been played.

Regards and check the online user manual 'Using Animations' for further info. Orthello User Manual

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.