Author Topic: Need help with vectors, positions and facing...  (Read 747 times)

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Need help with vectors, positions and facing...
« on: July 25, 2010, 08:17:46 pm »


               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.
               
               

               
            

Legacy_Genisys

  • Hero Member
  • *****
  • Posts: 961
  • Karma: +0/-0
Need help with vectors, positions and facing...
« Reply #1 on: July 25, 2010, 08:50:04 pm »


               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 .
                     
                  


            

Legacy_ChaosInTwilight

  • Full Member
  • ***
  • Posts: 126
  • Karma: +0/-0
Need help with vectors, positions and facing...
« Reply #2 on: July 25, 2010, 09:43:51 pm »


               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.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Need help with vectors, positions and facing...
« Reply #3 on: July 25, 2010, 10:19:54 pm »


               

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.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Need help with vectors, positions and facing...
« Reply #4 on: July 25, 2010, 10:34:42 pm »


               

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
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Need help with vectors, positions and facing...
« Reply #5 on: July 26, 2010, 12:34:14 am »


               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.