Author Topic: Getting angle to a node  (Read 399 times)

Galavant Garde

  • Full Member
  • ***
  • Posts: 160
  • Cayelan Mendoza
    • View Profile
    • Galavant Garde - Dark Electro Disco Pop
    • Email
Getting angle to a node
« on: December 07, 2017, 10:55:50 AM »
Hello there,

So I'm getting an error when I use map.node.getAngleTo(id); because it says it needs 4 parameters but can only find one.  That's when I put the ID of the node I want to get the angle to in the () brackets.  Am I doing it wrong?  Or is it maybe the documentation is for an older version of the command and needs to be updated?

Here's what I'm doing:

Code: [Select]
nearestNode=map.node.findNearestToObject(obj.setting.id);
angleToNode=map.node.getAngleTo(nearestNode);

The second line throws the error about parameters.  The reason I want to use this command is to check if the nearest node is behind the player.  I'll then check the next node in the path to see if it's also behind - if one is in front and the other is behind, I want the bot to skip the first node and start the path from the 2nd node.  That way they won't slingshot from one node to the next i.e. spin around to walk to the first node, then turn back around to walk to the second if you know what I mean

ggadwa

  • Administrator
  • Full Member
  • *****
  • Posts: 208
    • View Profile
    • Klink! Software
Re: Getting angle to a node
« Reply #1 on: December 07, 2017, 02:24:25 PM »
Hello there,

So I'm getting an error when I use map.node.getAngleTo(id); because it says it needs 4 parameters but can only find one.  That's when I put the ID of the node I want to get the angle to in the () brackets.  Am I doing it wrong?  Or is it maybe the documentation is for an older version of the command and needs to be updated?

Here's what I'm doing:

Code: [Select]
nearestNode=map.node.findNearestToObject(obj.setting.id);
angleToNode=map.node.getAngleTo(nearestNode);

The second line throws the error about parameters.  The reason I want to use this command is to check if the nearest node is behind the player.  I'll then check the next node in the path to see if it's also behind - if one is in front and the other is behind, I want the bot to skip the first node and start the path from the 2nd node.  That way they won't slingshot from one node to the next i.e. spin around to walk to the first node, then turn back around to walk to the second if you know what I mean

That looks like a bug -- but you are probably looking for:

Code: [Select]
nearestNodeId=map.node.findNearestToObject(obj.setting.id); // get nearest node id
ang=obj.getAngleTo(id,map.node.getPosition(nearestNodeId));

Galavant Garde

  • Full Member
  • ***
  • Posts: 160
  • Cayelan Mendoza
    • View Profile
    • Galavant Garde - Dark Electro Disco Pop
    • Email
Re: Getting angle to a node
« Reply #2 on: December 12, 2017, 12:42:12 PM »
Ace, thanks for that Brian  ;D