dim3 Forum

Full Version: Using the getAngleTo
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a feeling this will be another one of those solutions I'm going to hit myself over the simplicity of.

I can't get the map.object.getAngleTo command to work. Or rather, I don't understand how its input works.
Right now I have it going in like this:
ang=map.object.getAngleTo(id,x,z,y);
Not really sure what the x, z, and y parts of it are. Right not it doesn't give any errors, but it always tells me ang is now equal to [object d3_ang_class].
Are the x,y,and z paremeters supposed to fit into one variable?

I also tried putting the variable name in the corresponding y slot to see if that was where it goes, no luck either.
Look at this:
http://img249.imageshack.us/img249/7610/...etofb1.png
The green circle is the player (facing north).
The blue square is some other object.
Now you have to get the Player objects ID (there is an API for that) and the x,y,z coordinates of the blue object (there is an API for that too) and use them with map.object.getAngleTo(<unique ID of first object>,<x,y,z coordinates of second object>Wink; and it will return the angle (red the in the picture).
In this case 45°.
I think that's the way it works.

EDIT: Of course it doesn't have to be the player. You can do that with any other object too.
Yay for me for bringing up and old topic, but I'm still not getting this. I mean I understand what your saying Bink, and I put it in the right way, but I'm still getting nothing but [object d3_ang_class]. What does that mean excactly brian? I'm also getting this when I try to use map.object.getAngle(id); I assume you put in the objects id, it gives you the y angle its facing. But thats not happening.
Code:
getAngle(id);                               Returns object angle with x,y,z properties
getAngleTo(id,x,z,y);                       Returns object angle with x,y,z properties

This means that these functions do not return a simple integer or float value. You get an object back which has x, y, and z properties. So, you just need a little extra step in there to get the info you're looking for.

Code:
ang = map.object.getAngleTo( id, x, z, y );
yAng = ang.y;
Okay wow, thanks very much. I knew there had to be something like that in there. And it actually works now. woo.
Reference URL's