Forum rules - please read before posting.

How do i get the X and Y coordinates of the player and a NPC within the AC environment?

edited May 2014 in Technical Q&A
Would like to get the point that the user clicked for the player to go to in a scene and the current point that an NPC is standing within AC environment. Any help?

Comments

  • Provided you have a Paths component attached to the Player prefab, this will get you the end of the Player's path:

    if (GameObject.FindWithTag (Tags.player) && GameObject.FindWithTag (Tags.player).GetComponent <Paths>())
    {
      Paths p = GameObject.FindWithTag (Tags.player).GetComponent <Paths>();
      if (p.nodes.Count > 0)
      {
        Vector3 playerTarget = GetComponent <Paths>().nodes [GetComponent <Paths>().nodes.Count - 1];
      }
    }

    And to get the position of an NPC (set to the public variable myNPC):

    Vector3 npcPosition = myNPC.transform.position;
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.