Using Markers in 2D with Behaviours

Oliver Marshall 10 months ago in Behavior updated by Marti (Lead Developer) 9 months ago 9


I want to create a patrol route for an NPC in my 2D game. However, I can't see a way to refer to Markers within Behaviours. 

There's nothing really in the docs on how to use Markers other than to explain what they are. 

Does anyone have any guidance on how to use Markers and make an NPC move to one?


Unity version:
Game Creator version:

Hi Oliver!

If you use the "Move Character To" Action and set it to Marker, you'll be able to go to a Marker and copy its direction right? But from a Behavior Graph you can't reference a scene game object.

However, a hidden feature of Game Creator is that, if you use a Game Object as the target of the "Move Character To" Action and drop in a Marker, it will use it as a Marker too.

So, in your Graph Blackboard, create a new entry and set it to type "Game Object". From the Behavior component, you can drop in the Marker game object.

I agree that this is a bit hidden and we'll update the documentation accordingly to accommodate this information. We had to add this when designing the Behavior module because of the restriction of not being able to reference scene objects from a scriptable object.

If there's any issue, please let me know in the comments below :-)


I've tried adding an entry to the blackboard as a type GameObject. I've dropped the Marker from the hierarchy on to the inspector field for the behaviour, but when I play with the Move To action in the behaviour, I can't see the Marker in the Marker selector. I also can't see it in any of the other options (Transform, Variables etc).

Any ideas?

Almost there! The Blackboard acts as a "Local Variable" container for the Invoker. So to select the Blackboard variable, all you need to do is, go to the "Move Character To" Action (last screenshot) and where it says "Move To" dropdown, select Local Variable. Now, set the target as "Invoker", which refers to the object executing this Behavior. Lastly, type in the text "Marker1" as the variable name.

That should do the trick. Let me know if there are any issues. Cheers!

Right, thanks. 

That done, I now get an error at least. 

The error is:

An object exists in the scene which is called Marker and has the navigation Maker script assigned.

The NPC has the behaviour assigned and the DestMarker variable, set from the blackboard, is set to point to the marker object.

The Task properties in the behaviour are as follows. DestMarker is the name of the blackboard entry.


Hmm the error is related to the Character system. The Character component from Game Creator has a field called CharacterLocomotion, which handles moving the character around. However, you mentioned you're using a custom 2D character controller you might not have this functionality enabled.

How are you creating your controller? Not sure if you're a programmer though. If you need help converting your custom character controller to GC compatible, feel free to email us your code (in case you don't want to post it here).


I *think* the player controller is copied from one of the Unity tutorials. The NPCs, which are the characters I'm wanting to move between markers, they have no controllers at all assigned to them. They are just dumb stand-still objects at the moment. 

The player controller is this:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
    public float moveSpeed = 5f;
    public Rigidbody2D rb;

    public Animator animator;

    Vector2 movement;

    // Update is called once per frame
    void Update()
        movement.x = Input.GetAxisRaw("Horizontal");
        movement.y = Input.GetAxisRaw("Vertical");

        animator.SetFloat("Horizontal", movement.x);
        animator.SetFloat("Vertical", movement.y);
        animator.SetFloat("Speed", movement.sqrMagnitude);


    private void FixedUpdate()
        rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);

Ah then yes. The problem is in your character controller. You can't use "any" controller, since the Move Character To action expects certain code to be in the character that allows it to move, finding the shortest path to its destination. The code you posted simply takes the player's input and sends the info to an animator.


ahh righto.

Ill rummage around the docs for a 2D controller then. Feel free to add more 2D support 😀

Definitely it's a field we'll explore in a future major release :-) We wanted to start with something "simple" which is easier to maintain and debug. Now that GC's core foundations are pretty clear and solid, we'll investigate expanding it to new dimensions (but on a major release most likely).