# Setting the angle

## Recommended Posts

Hello

I know that it is possible to create a coordinate out of an angle using those bastards sinus and cosine. It was used in VC a few times mainly in missions where object scattering is used (like pizza boy) where an object is scattered in a specific direction depending on your z angle.

What I want to know is if it possible to make an opposite effect - create an angle out of a coordinate. Is it possible to make that depending on players position an actor or an object or a vehicle (like...dunno...hunter ) would turn such angle that he/it would keep facing the player? I really suck at maths so I'm asking for your help

##### Share on other sites

Well, SA has 0604 opcode, which makes it possible, VC don't have. Perhaps atan will help.

GTA: Frosted Winter for GTA: Liberty City mod comes?

##### Share on other sites

GTA: Frosted Winter for GTA: Liberty City mod comes?

Not exactly

##### Share on other sites

hmmm... I made some of that things a few weeks ago (to make a weapon always face the target) what you must do is to get the absolute angle between the two points (this is according to only those two points) and then get the z angle of the actor you want to face at you, then get the difference between the two angles and that is the absolute Z angle (according to the game XYZ) the actor (you want to face at you) must be rotated to be always facing at you... if that doesnt works try adding the absolute angle (between the two points) to the absolute z angle of the actor you want to face at you and setting that to be the actor's z angle...

##### Share on other sites

I'm sorry, but I do not understand how to do that in VC. You say to find an absolute angle between two points. I imagine you men the player and the actor/car I want to rotate. But the only way I imagine is to make a triangle between points: you, actor and a point perpendicular to both you and actor. I may find all distances between the points and try using maths but all i could find is a sinus or a cosine of an angle between point you and point actor. But I don't know such opcode in VC which translates a value of sinus into a value of an angle Or maybe I'm thinking wrong?

##### Share on other sites

hmmm... I made some of that things a few weeks ago (to make a weapon always face the target) what you must do is to get the absolute angle between the two points (this is according to only those two points) and then get the z angle of the actor you want to face at you, then get the difference between the two angles and that is the absolute Z angle (according to the game XYZ) the actor (you want to face at you) must be rotated to be always facing at you... if that doesnt works try adding the absolute angle (between the two points) to the absolute z angle of the actor you want to face at you and setting that to be the actor's z angle...

Said the same earlier. 0604 does not exist in VC.

I think that the only way is making similar function via ASM (still not sure about atan). I'll play around it.

Edit:

Well, 0604 opcode does

`v37 = CGeneral__getATanOfXY(*(float *)&opcodeParameters, *((float *)&opcodeParameters + 1)) * 57.2957763671875         - 90.0;`

so atan should be fine. It will require CLEO though.

Edit2:

Try this:

`// 0@ 1@ 2@ contains one of the coords// 3@ 4@ 5@ contains another coords0063: 0@ -= 3@  // (float)0063: 1@ -= 4@  // (float)05E2: call_function 0x4A55E0 num_params 2 pop 2 0@ 1@ 6@// 6@ contains atan result`

Untested, you may play around maths.

Edited by SilentPL
##### Share on other sites

Ok thanx I'll see what I can do.

P.S. I know its a wrong place, but maybe someone knows someone who could do some modelling? Please

## Create an account

Register a new account

×