Aller au contenu

Photo

Need help with vectors, positions and facing...


  • Veuillez vous connecter pour répondre
5 réponses à ce sujet

#1
Shadooow

Shadooow
  • Members
  • 4 468 messages
Yes, Im so ashamed, but I can't figure it out myself.

I have problem, I want to spawn NPC at random position in room, but I want she to spawn faced toward to object in middle of room. Until now I believed I got correct formula,

vector vObjectPosition = GetPosition(oObject);
vector vNewPosition = [randomized from vObjectPosition];
float fNewFacing = VectorToAngle(vObjectPosition-vNewPosition);

but further testing proofed its not correct. Does anyone know how to count proper facing? Thanks.

#2
Genisys

Genisys
  • Members
  • 525 messages
You could use two scripts, one to do the random spawn in position, then in the OnSpawn script of the spawned in creature, make them face the target & possibly get the current vector / position..

Or you could create a custom function, which would then need to be delayed in order to "find" the spawned in creature after it has spawned, then make it do actions, apply effects, or to get the position of the creature...

You may need to do two custom functions, the 3rd custom function would run from the 2nd function to do actions, after the creature is "Found" & "Located", to apply affects or do actions etc...

That help?

Modifié par Genisys, 25 juillet 2010 - 07:52 .


#3
ChaosInTwilight

ChaosInTwilight
  • Members
  • 89 messages
Pretty sure the script commands all think direction is off by 90 degree's.



Forget if it was clockwise, or counter, but I had a heck of a time with it back in the day.

#4
Shadooow

Shadooow
  • Members
  • 4 468 messages

Genisys wrote...

You could use two scripts, one to do the random spawn in position, then in the OnSpawn script of the spawned in creature, make them face the target & possibly get the current vector / position..

Or you could create a custom function, which would then need to be delayed in order to "find" the spawned in creature after it has spawned, then make it do actions, apply effects, or to get the position of the creature...

You may need to do two custom functions, the 3rd custom function would run from the 2nd function to do actions, after the creature is "Found" & "Located", to apply affects or do actions etc...

That help?

nope, I know i can use SetFacingPoint after creature is spawned, but this creature has EffectAppear animation so its seen she is faced into wall and I dont want that.

#5
Shadooow

Shadooow
  • Members
  • 4 468 messages

ChaosInTwilight wrote...

Pretty sure the script commands all think direction is off by 90 degree's.

Forget if it was clockwise, or counter, but I had a heck of a time with it back in the day.

Ahh got it. I thought the values are incorrect because I got 180° when I assumed I need 270, since I knew where is north, however it seems that you are right and all scripting commands think the north is 90 degrees clockwise, so my function is correct.

thanks

#6
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Just a note; Here is how bioware defined the orientation.



x and y components of a unit vector that points in the

direction that the waypoint faces.

Or in other words, the cosine and sine, respectively, of

the waypoint's bearing in the xy plane, measured as an

angle counterclockwise from the positive x-axis.