Forum rules - please read before posting.

Moving characters in sync with another animation and showing standard animations simultaneously

In my 2D 320x180 px point and click adventure game I have a scene where two characters are sitting on a boat, having a discussion. The view is "locked" on the boat and the scenery is flashing by in the background. However, as the speed is high, the boat is still bouncing around a bit on the waves. The boat sprite animation is a 15 frame looping animation cycle played at 50 fps with frames set at 5 sample (0.1 sec) intervals. The X and Y coordinates of the seat of the boat are changing a few pixels here and there in each frame (but obviously repeating the same movement pattern over and over).

What I want to do is to have the two characters "glued" sitting on the boat seat so that they'll move in sync with the boat's motion. I've tried to achieve this by first tracking the pixel-by-pixel movement the boat makes during the 15 frame cycle, then creating an actionlist where I move the characters' X and Y coordinates using Object: Transform's "Translate By" command with 0.1 second intervals throughout the boat animation loop.

Now after hours of trying, it doesn't seem I can get the boat animation and the characters' position changes via the actionlist commands in sync. It's never perfect (although looks best during the first cycle). With time, it goes more and more off sync (on my slower office computer though, it seems to be off sync from the get-go). Is there something that affects the characters' movement in AC or Unity I'm not taking into account? I'm aware of this issue (still using Unity 2019.4.17f1 and AC v1.72.4) and tried different things but none of them worked: https://forum.unity.com/threads/looping-an-animation-should-the-last-frame-be-duplicated-one-or-two-frames-later.770591/

I chose to try this (perhaps somewhat unorthodox) approach of attempting to match the boat's movements with actionlist commands because during the conversation, I need the characters to play idle, talk and special hand gesture animations etc. so I thought it would be simplest to have one system (in this case, the actionlist movement commands) take care of moving the characters according to the boat animation's "path" so that we're free to play the standard animations. This would mean that wherever we are in the boat's movement cycle when, say, a talk animation should commence, we could play it no problem.

Now, the question: how should one approach something like this?

Comments

  • edited February 10

    It's a bit of a unique situation, but I'd try using Empty child objects, attached to the boat, that represent where the two characters should be positioned - and then animate their positions as part of the boat's sprite animation.

    You'd need to make sure the animatino curves use Constant interpolation, but it should then just be a case of keeping the two characters snapped to their respective empties - which could be done with a simple script calling the character's Teleport function, i.e.:

    using UnityEngine;
    public class SnapCharacterToEmpty : MonoBehaviour
    {
    
        public AC.Char character;
        public Transform snapTo;
    
        void Update ()
        {
            character.Teleport (snapTo.position);
        }
    
    }
    
  • Thank you kindly. This did the trick. :)

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.