An object facing the players X, Y -
Lorenc_ - 23.06.2011
Hi, this might be one of the most lame questions though note i hardly ever work with angles, If i have an andromada above me I want it to face the players X, Y and want it to fly as well in that direction:
Diagram
pawn Код:
CMD:fly(playerid, params[])
{
new Float: pos[3], Float:Height, Float:unKnown[2];
GetXYInFrontOfPlayer(playerid, pos[0], pos[1], 100.0);
GetPlayerPos(playerid, unKnown[0], unKnown[1], Height);
gPlayerData[playerid][E_AIRSTRIKE_AROMANDA] = CreateObject(14553,pos[0]-55,pos[1],Height+75,0, 0, 90);
MoveObject(gPlayerData[playerid][E_AIRSTRIKE_AROMANDA], pos[0]+ 260, pos[1], Height + 80, 29);
}
Old command i created a while back, I doubt it works. Every attempt i tried i failed, I hope someone knows this
Re: An object facing the players X, Y -
Sascha - 23.06.2011
ok I've painted a little image which could maybe help you... it just shows some basics (no clue if that helps you at all or if I just summed up some stuff that you already know)..
I can't really help you any more with this, as I can't really figure it out.. I've already wasted a few pieces of paper with some coordinate systems and drawings, however I didn't get the result yet (maybe later, I'll continue thinking)..
with my image you will however just find out the angle to the player...
you'll have to figure out if the player is left or right and stuff by the coords..
Re: An object facing the players X, Y -
Lorenc_ - 23.06.2011
Quote:
Originally Posted by Sascha
ok I've painted a little image which could maybe help you... it just shows some basics (no clue if that helps you at all or if I just summed up some stuff that you already know)..
I can't really help you any more with this, as I can't really figure it out.. I've already wasted a few pieces of paper with some coordinate systems and drawings, however I didn't get the result yet (maybe later, I'll continue thinking)..
with my image you will however just find out the angle to the player...
you'll have to figure out if the player is left or right and stuff by the coords..
|
Damn, I wish there was a topic to have a solution to this, I thought it would be an easy job but it isnt what I expected :/
Re: An object facing the players X, Y -
Sasino97 - 23.06.2011
You can use AttachObjectToPlayer, but you can't detach it
Re: An object facing the players X, Y -
Babul - 23.06.2011
if i didnt read your command wrong, you want to achieve that a plane starts to fly behind a player to his facing position to drop some bombs, right? thats the only safe way for a hitman to launch an airstrike on a position like 100 meters infront of him
so if iam not totally wrong, plz confirm it, i just want to make sure that i dont script something useless...
Re: An object facing the players X, Y -
Sasino97 - 23.06.2011
Quote:
Originally Posted by Babul
if i didnt read your command wrong, you want to achieve that a plane starts to fly behind a player to his facing position to drop some bombs, right? thats the only safe way for a hitman to launch an airstrike on a position like 100 meters infront of him
so if iam not totally wrong, plz confirm it, i just want to make sure that i dont script something useless...
|
Lol I readed wrong, I understood that he wants to attach the plane
Re: An object facing the players X, Y -
Babul - 23.06.2011
it seems that the plane is supposed to appear behind the Player (facing the Target), and fly to the position. to obtain the plane start position can be tricky, or easy...
tricky way: calculate it per sinus/conisnus transformations. waste of time in this case, coz the...
easy way: subtract the player position from the target position. you will get the offset. then simply subtract the offset from the players position again, you will get the mirrored side, the plane starting position
Код:
Target @ 1290,1490,1 ...the target position is east, and a little south of the player. thats like a degree of 95?
Player @ 1200,1500,0 ...just a random coordinate...
...the difference is: 1290-1200 = 90 and 1490-1500 = -10 and 1-0 = 1
...so the start is: 1200-90 = 1110 and 1500-(-10)= 1510 and 0-1 = -1
Start @ 1110,1510,-1
hope that helps a bit
edit: oh, my plane would be a goundhog. indeed add some units at the z axis for the planes' position ^^
Re: An object facing the players X, Y -
PCheriyan007 - 23.06.2011
I guess it would be a combination of Move(Dynamic)Object and GetPlayerPos, as well as setting the Z-Axis of the plane to 100+ where the player is.
Re: An object facing the players X, Y -
Sascha - 23.06.2011
Quote:
Originally Posted by Babul
it seems that the plane is supposed to appear behind the Player (facing the Target), and fly to the position. to obtain the plane start position can be tricky, or easy...
tricky way: calculate it per sinus/conisnus transformations. waste of time in this case, coz the...
easy way: subtract the player position from the target position. you will get the offset. then simply subtract the offset from the players position again, you will get the mirrored side, the plane starting position
Код:
Target @ 1290,1490,1 ...the target position is east, and a little south of the player. thats like a degree of 95?
Player @ 1200,1500,0 ...just a random coordinate...
...the difference is: 1290-1200 = 90 and 1490-1500 = -10 and 1-0 = 1
...so the start is: 1200-90 = 1110 and 1500-(-10)= 1510 and 0-1 = -1
Start @ 1110,1510,-1
hope that helps a bit
edit: oh, my plane would be a goundhog. indeed add some units at the z axis for the planes' position ^^
|
either I don't get it right or I am right with this question (:P) :
That wouldn't solve the andro's heading problem, which seems to be the actual problem >> figuring the rotation of the andro out, so that it looks into the direction it flies.
Re: An object facing the players X, Y -
Lorenc_ - 24.06.2011
Quote:
Originally Posted by Babul
if i didnt read your command wrong, you want to achieve that a plane starts to fly behind a player to his facing position to drop some bombs, right? thats the only safe way for a hitman to launch an airstrike on a position like 100 meters infront of him
so if iam not totally wrong, plz confirm it, i just want to make sure that i dont script something useless...
|
Just what you said
, This explains it.
I want this... ^^^