Waldemar 337 12 Posted April 17, 2022 Which is the most efficient way to move the position by a vector ? I don't think that the + operator in SQF is capable of doing it. The vectorAdd function ( https://community.bistudio.com/wiki/vectorAdd ) sums two vector operands. I need to apply a vector to a 3D point which is a position. E.g. (position player) += delta_vector; _obj setPos ((position _obj) vectorAdd delta); Will this work ? Thank you. Share this post Link to post Share on other sites
dreadedentity 278 Posted April 17, 2022 Best way to find out if something "will work" is to just try it vectorAdd will add 2 2-element or 3-element arrays as if: { _vector1 set [_forEachIndex, (_vector1 # _forEachIndex) + _x; } forEach _vector2; Or in other words, it will add each position in the arrays together. So if that's the behavior you're looking for then yes Also yes because this is specifically what I use when I want to move something relative to it's current position 1 Share this post Link to post Share on other sites
pierremgi 4945 Posted April 18, 2022 13 hours ago, Waldemar 337 said: Which is the most efficient way to move the position by a vector ? I don't think that the + operator in SQF is capable of doing it. The vectorAdd function ( https://community.bistudio.com/wiki/vectorAdd ) sums two vector operands. I need to apply a vector to a 3D point which is a position. E.g. (position player) += delta_vector; _obj setPos ((position _obj) vectorAdd delta); Will this work ? Thank you. It's confusing, using absolute player position as a relative vector.... What is your goal exactly, between player and object? Share this post Link to post Share on other sites
Waldemar 337 12 Posted April 18, 2022 I wanted to create an object infront of the player. At the moment I found a simple solution, but I do not know whether it is efficient or not. _vehPos = (position _caller) vectorAdd ((vectorDir _caller) vectorMultiply (k)); Why is it confusing ? What is the better way ? Share this post Link to post Share on other sites
_foley 192 Posted April 18, 2022 Here https://community.bistudio.com/wiki/modelToWorld _aboveAndBehindPlayer = player modelToWorld [0,-1,3]; 1 Share this post Link to post Share on other sites
dreadedentity 278 Posted April 18, 2022 37 minutes ago, Waldemar 337 said: I wanted to create an object infront of the player. So there are several ways you can do this: player setPos ((getPos player) vectorAdd [0,5,0]); player setPos (player getPos [5,0]); player modelToWorld [0,5,0]; //@_foley All of these are roughly equivalent in effect (no idea about performance), though due to the nature of getPos and setPos to change context over land vs water, some may have weird side effects 1 Share this post Link to post Share on other sites