Forum rules - please read before posting.

QTE progress linked to animation frames + question about custom controller and cutscenes.

I’ve been Planning on using QTEs in my game to handle escaping from being grabbed by enemies, upon going through the QTE tutorial I noticed this line:

>Be aware that - through custom scripting - we can affect any UI element to represent the time remaining. For example, we could use an Image's "fill amount" value instead. To get the time remaining as a decimal between 0 and 1, we can use this simple function:

Would it be possible to convert the time remaining into an animator variable, and use that to control an animation, so that for example, as you mash a button, you can advance through the frames of your player pushing something away, and as you miss prompts, the animation essentially rewinds?
On a failure I would ideally want an animation of getting bitten to play (and I’d reduce player health then release them from the grab and start a cool down on enemy grab attacks to prevent getting stun locked etc)


The other quick question I had was regarding custom controls and animations playing nicely with cutscenes.

Since I’m using completely custom controls and animations I find that it is impossible to have the player do what I want when using action lists in cutscenes (for example, having them move somewhere won’t necessarily play their walking animation whilst it will relocate the actual game object)
I was wondering if there’s a way to access the scripts for some of those action list actions to add in little lines that will trigger animations whatnot based on my own variable names.

Other alternative would be to switch the player to one that uses standard AC controls and animations and have them do their thing until the cutscenes are over, then switch back - not really a huge deal either way.

Just as a note, the reason I went with custom controls and animations is that the third person, fixed camera system with non tank controls enabled doesn’t seem to take into account the direction your character was already moving in when a camera switch occurs. Essentially what happens is you could be pressing left to walk left, the camera switches so what was left before is now forward, and immediately your character changes direction to the new left based on the new camera.

My code makes a reference to the camera’s facing before any movement occurs and uses that to control the player character until the movement key is released, at which point the new camera directions become the reference.

Comments

  • edited March 2021

    Would it be possible to convert the time remaining into an animator variable, and use that to control an animation

    Yes, the function returns a float - which can be passed to an Animator float paramater:

    public Animator myAnimator;
    void Update ()
    {
        myAnimator.GetFloat ("TimeRemaining", AC.KickStarter.playerQTE.GetRemainingTimeFactor ());
    }
    

    You should then be able to use that to drive an animation's playback state with Direct Blending.

    I was wondering if there’s a way to access the scripts for some of those action list actions to add in little lines that will trigger animations whatnot based on my own variable names.

    You can click the cog to the top-right of an Action, or in its entry in the Actions Manager, to get an "Edit Script" option to open the Action's source.

    Other alternative would be to switch the player to one that uses standard AC controls and animations and have them do their thing until the cutscenes are over, then switch back - not really a huge deal either way.

    Are you meaning that you're relying on a custom motion controller, but still want to rely on AC movement commands?

    There are a couple of ways to do this - which way you go really depends on the circumstance, though.

    The first is to simply set the Player's Motion control field from Manual to Automatic when a cutscene begins, and vice-versa when gameplay resumes. This can be done with script:

    using UnityEngine;
    using AC;
    
    public class TogglePlayerMotionControl : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnEnterGameState += EnterGameState; }
        private void OnDisable () { EventManager.OnEnterGameState -= EnterGameState; }
    
        private void EnterGameState (GameState gameState)
        {
            if (gameState == GameState.Normal)
            {
                KickStarter.player.motionControl = MotionControl.Manual;
            }
            else if (gameState == GameState.Cutscene)
            {
                KickStarter.player.motionControl = MotionControl.Automatic;
            }
        }
    
    }
    

    The second - more complicated, but more robust - way is to read the functions provided by the Player script to get the character's intended position and rotation (limited to just during cutscenes if necessary). For more on this topic, see this tutorial.

    the third person, fixed camera system with non tank controls enabled doesn’t seem to take into account the direction your character was already moving in when a camera switch occurs.

    It should account for this, actually. Upon switching camera, the player's direction should remain unchanged until the input direction changes by an angle of 5 degrees. If you're interested in debugging, this is handeld in the "cameraLockSnap" code block in PlayerInput.cs, around line 1324:

    if (cameraLockSnap)
    {
        Vector2 newMoveKeys = new Vector2 (h, v);
        if (newMoveKeys.sqrMagnitude < 0.01f || Vector2.Angle (newMoveKeys, moveKeys) > 5f)
        {
            cameraLockSnap = false;
            return newMoveKeys;
        }
        return moveKeys;
    }
    
  • Hi Chris, thanks once again for your help.
    I’ve got the QTE animations all sorted now.
    As far as motion controls go, I think my issue was that I was using cinemachine with custom movement and animation state machines, so it was hard to figure where to “plug” AC into the mess I made.
    I created a fresh project and saw that the direct controls do indeed work the way I wanted, but I had obviously ballsed something up on my end.
    I’ve opted to carry on using my spaghetti script for now and simply switch things to automatic for cutscenes, since I have a bunch of shooting stuff in there too, but when I begin tidying things up and splitting scripts up, I will likely either go with vanilla controls or do as you’ve suggested with the tutorial.
    Thanks heaps!

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.