Forum rules - please read before posting.

Walk to marker proximity

Hotspots have a feature where you can create a marker and set a minimum distance. I find this really useful when dealing with NPC hotspots because you can click an NPC to talk to them, and no matter where the player is walking from, they will stop before they are standing on top of the NPC.

Now I'm creating a cutscene where an NPC first pathfinds to the player, then speaks to them. I do this by adding a marker child to the player, and telling the NPC to "move to point". The issue here is that as expected the NPC will move exactly where the marker is, and offsetting the marker doesn't work because I need the NPC to stop at a distance from whatever direction they are walking from.

Does this feature already exist and I just can't see it? If not, do you think it could be added to the "move to point" action?

Comments

  • Not currently, but I will consider it.

    This can be achieved with a simple script attached to the NPC, however:

    using UnityEngine;
    using AC;
    
    public class ApproachPlayer : MonoBehaviour
    {
    
        public NPC npc;
        public float minSqrDistance = 1f;
    
        void Update ()
        {
            if (npc.IsPathfinding () && (npc.GetPath ().Destination - KickStarter.player.transform.position).sqrMagnitude < 0.1f)
            {
                if ((npc.Transform.position - npc.GetPath ().Destination).sqrMagnitude < minSqrDistance)
                {
                    npc.EndPath ();
                }
            }
        }
    
    }
    
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.