Aller au contenu

Photo

is there a function that gets the individual component values of a vector?


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

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I want to retrieve the X,Y,Z components of a vector.  Is there a function that does this?

#2
Shaughn78

Shaughn78
  • Members
  • 637 messages
GetPosition() will give you the vector.

#3
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
You don't have to, it's part of the vector

if you have

vector vLocation = LocationToVector( GetLocation(OBJECT_SELF));

float fVarx = vLocation.x;
float fVary = vLocation.y;
float fVarz = vLocation.z;

You can also just use the vector itself, as above and treat it like a float.

More examples are in this, which can be pretty much used as is
Common Script Library - Position

#4
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Thanks for the response Shaughn. I wasn't completely clear about what I am trying to do. I just wanted to get the Z value from the vector so I could change it, but I figured out a way around my problem. I want to change the height of an object during runtime. I figured out how to do it. I got the vector then added another vector to it. The vector I added only had the z value. It worked great.