Jump to content

How to get NPC rotation?


Recommended Posts

Posted (edited)

This has been partially solved, please scroll down to my next reply for the solution

 

 

So for my script I need to find out which way my NPC is walking. I've checked the API and did some googling to find that: npcs.closest(id).getRotation would work, however it looks like it has been depricated in the API.

 

I can't see anything in the NPCS that would help me find the solution to this.

 

I know I could grab 2 positions of the NPC and work out the direction myself, but my script is heavily reliant on timing and leaves me with not much room to do this calculation.  I could make it work for my script so it's not the end of the world, it's just that I'd like to aviod rewriting functions.

 

So, any clean way to get the rotation of an NPC without having to take 2 positions? Thanks.

Edited by zappa2010
Posted

Hey, I managed to resolve the problem thanks to FrostBug.

 

Dumbass me had the wrong type. Here's my line of code:

Entity npc1 = npcs.closest(id);

The .getRotation belongs to the Character type and needs casting from NPC.

So if you have this problem and need to get the N/E/S/W position of an NPC, you need to change the type to NPC like so:

NPC npc1 = npcs.closest(id);
int rot = npc1.getRotation();

I'm still stuck on what .getRotation returns.

Is this correct?

1-North

2- East

3- South

4- West

 

or is it..

0-North

1-East

2-South

3-West

 

or something I've missed completly?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...