Forum rules - please read before posting.

Custom Movement (Motion Control): Tips for implementation

Hey everybody,
hey Chris!

I need some advice on how to implement custom motion. If I set "Motion Control" to "Custom", do I have to code all functionality for sprite flipping, animations, etc. myself? Or is there a way to only change how the actual motion of the Player is handled?

In my scenario I combine controller controls with a NavMesh agent. How can I set the NavMesh agent so it has the same speed and other values just like my AC Player? Because it seems like the AC speed is a bit different than the NavMesh agent speed, but maybe I'm mistaken.

My main concern is if there is an easier way to change the way my Player is controlled without having to "imitate" AC's default functionality.

Your answers and suggestions are highly appreciated!

Comments

  • Animation and motion are separated where possible - the "Animation engine" can be set independently of the "Motion control" field.

    There's no "Custom" motion control option - but "Manual" will reliquinquish any control has over the character's position and rotation. Their animation engine will still read their rotation to control the correct sprite direction.

    A tutorial on motion controllers can be found here, but if you're just looking to make use of the NavMesh Agent component, AC has a built-in integration for that. Just attach the NavMesh Agent Integration component, and AC will rely on it for motion. If the behaviour differs from your exact needs, it may be easiest to duplicate the script and tweak as necessary.

  • Thank you Chris, of course I meant "Manual" motion control. Also I was reading the tutorial but I don't quite get it. I have my player set to manual motion control, but "Animation Engine":"Sprites Unity". Now I have a NavMeshAgent and my custom control script on the Player. But how can I tell AC that the player is moving and in what direction? I don't quite understand how to make that connection. Sorry if dumb...

  • It depends on how you're using the motion controller - are you having it read AC's "intended" position based on the built in e.g. Point And Click movement method, or are they moving under entirely custom means without AC's involvement?

    If you can share details on the exact situation, your Settings Manager, as well as the custom control script you're using, I can give more specific advice.

  • Thanks so much Chris! The thing is, I want to develop a system that I can import into concrete projects, but I would like to have scripts set everything necessary, so I don't have to note or remember what I need to change in the Settings Manager.

    My exact situation: my game should be playable in two input modes: the usual point and click mode and one that is completely playable with only a controller and without the need for a cursor that the player navigates with a joystick. That seems like a bigger challenge than I anticipated, since I also don't know yet what the best approach is to make stuff like inventory cycling, combining items (with each other and with the environment), etc.

    But one step at a time and now I would like to have a control script that let's me navigate the player around a NavMeshSurface without the need for colliders and with just the controller input. My script is working, but it requires me to handle animations, flipping etc. myself, since I'm changing the position of the Player GameObject and this way AC can't know that the Player is moving and what direction the Player is moving in. I thought maybe there is a way to tell AC "player is moving now", "player is facing direction x", etc. and AC handles the rest (animations, flipping and so on).

    Maybe what I'm trying to do here is not possible, but I wanted to ask here before going down the wrong path.

  • my game should be playable in two input modes: the usual point and click mode and one that is completely playable with only a controller and without the need for a cursor that the player navigates with a joystick.

    An example script that allows for this behaviour can be found on the AC wiki:

    https://adventure-creator.fandom.com/wiki/Switching_input_method_dynamically

    But one step at a time and now I would like to have a control script that let's me navigate the player around a NavMeshSurface without the need for colliders and with just the controller input.

    From this alone, I'm not sure you require a custom motion controller - the NavMesh Agent Integration component will have this behaviour if your Movement method is set to Direct. Wall colliders are not necessary - they will stick to the NavMesh boundary automatically.

    Purely in motion terms, does this component's behaviour differ from your intent when testing?

    The thing is, I want to develop a system that I can import into concrete projects, but I would like to have scripts set everything necessary, so I don't have to note or remember what I need to change in the Settings Manager.

    Once the exact prefabs/scripts are determined, you could conceivably create a custom template that you can use to install this behaviour in your projects.

    Custom templates can be created just by deriving an Editor script from AC's Template class. With proper configuring, they can also be shown in the New Game Wizard.

  • edited October 2024

    Thank you Chris!

    Dynamic input switching already works like a charm, but what I don't understand is

    "Wall colliders are not necessary - they will stick to the NavMesh boundary automatically."

    Do you mean, with a custom script or should this be the default behavior? Because when I switch to direct, the Player is ignoring the NavMesh. It is a 3D game, maybe that makes it more difficult?

  • It should be the default behaviour - provided your Movement method is Direct, and you're using the latest release. What's your AC version?

  • I now upgraded to 1.81.7, but the player is still not confined to the NavMesh in direct control mode. My Player has no Rigidbody and ignores gravity. Are there any specific settings or components that are necessary for this to work?

  • It should be automatic, with those conditions.

    Can you share screenshots of your scene, the Settings Manager, and Player Inspector?

    The code to make this happen is in the NavMeshAgentIntegration script's first if block in its Update function - try placing a Debug.Log in there to make sure it's being run.

  • edited October 2024

    I didn't understand that for this I have to add a NavMeshAgent, now it works. So awesome! Thanks so much!

    I don't suppose there is also already a way to completely switch to controller, without the need for a cursor? (With inventory interactions etc.)

  • Yes, the cursor is only optional depending on your settings.

    You can lock the cursor by default in the Settings Manager's "Interface" panel. If your game is played without a mouse, switch your Input method to Keyboard Or Controller.

    Menu interactions can optionally be handled via direct navigation as opposed to the cursor - see the Manual's "Navigating menus directly" chapter for details.

  • Incredible, I thought I would have to code all of this by myself. Amazing! I will read more into it, thanks so much!

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.