Forum rules - please read before posting.

How to make the player move forward on a path on specific input

Hi everyone! I'm new here!

So I'm making an isometric game and I want the player to move forward along a path when pressing a single button.

I'm using Player:Lock to Path, and it's working as it should. But my problem is that I want the player to move forward when press a specific button (space, for example), right now the player only moves if I press the same direction of the next node.

Image:
https://drive.google.com/file/d/10agyIhEY7lqKjhu3Q0n8TIB9Stt0sClN/view?usp=sharing

Movement Method is "Direct" and Direction-movement Type is "relative to camera" (tried "Tank" but did not work either)

Maybe i'm missing something!

Thanks!

Comments

  • Welcome to the community, @hncarlos!

    To achieve, this, you'd need to temporarily disable AC's Movement system in favour of a custom script.

    Try the one below by placing it in a C# script file named MovePlayerPath and attaching it to a GameObject in your scene. You'll need to define an input in its Inspector - this should be the name of an input defined in your Input Manager, rather than the name of the input key needed to press:

    using UnityEngine;
    using AC;
    
    public class MovePlayerPath : MonoBehaviour
    {
    
        public string inputButton = "MovePlayer";
    
        void Update ()
        {
            if (KickStarter.player.IsLockedToPath ())
            {
                KickStarter.stateHandler.SetMovementSystem (false);
    
                bool inputHeld = Input.GetButton (inputButton);
                if (inputHeld)
                {
                    KickStarter.player.isRunning = KickStarter.playerInput.IsPlayerControlledRunning ();
                    KickStarter.player.charState = CharState.Move;
                }
                else if (KickStarter.player.charState == CharState.Move)
                {
                    KickStarter.player.StartDecelerating ();
                }
            }
            else
            {
                KickStarter.stateHandler.SetMovementSystem (true);
            }
        }
    
    }
    
  • edited July 2022

    Thanks! It worked! :)

    I have to say, AC is amazing! It changed completely the way I create games! Thanks for that too!

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.