Jump to content
Sign in to follow this  
nuxil

setvectorUp or setvectorDir ??

Recommended Posts

If i know the position of A and B, and I know the distance of from A to B.. and i know the heading from A to B, i also know the hight of A and B,, so how can i the set obj A to face "point" at obj B whith eighter setvectorUp or setvectorDir,

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Pa = getpos A;

_Pb = getpos B;

_Pab = [(_Pb select 0 - _Pa select 0), (_Pb select 1 - _Pa select 1),(_Pb select 2 - _Pa select 2)];

_objA setVectorDir _Pab;

Share this post


Link to post
Share on other sites

since i'm a lazy guy (aren't we all wink_o.gif ) and i don't wanna spend hours trying to figure it out i'm gonna follow up on that question with another one:

if A and B aren't at the same height, how do i calculate the upvector of A so that i can use setvectorup to make object A point straight at object B (i'm talking pitch here)? basic math, i know, but it's been sooo long wink_o.gif

Share this post


Link to post
Share on other sites

I like to know that too..

i know how to get the angel tho..

but not how to use it with vectoup.

forexample..

objA = Aax,Aay,Aaz.

objB = Bbx,Bby,Bbz.

// use this

g0 = Bbx,Bby,0 "make a triangle"

tan angel = (( Bbz distance g0 ) / ( objA distance objB ))

atan angle = angle in deg,,

PS.. i whish ther was a "setdir" to Z cordites :P

Share this post


Link to post
Share on other sites

hehe i dont get it im still as confused as i was..

Code Sample

_Pa = getpos A;

_Pb = getpos B;

_Pab = [(_Pb select 0 - _Pa select 0), (_Pb select 1 - _Pa select 1),(_Pb select 2 - _Pa select 2)];

_objA setVectorDir _Pab;

kinda worked.

but if i changed it to setVectorUp _Pab instead..

i got better results..

obj B faces me in "xyz" cords..VS setVectorDir that only seems x.y,z where z=speed up/down with the objects current rotation "vectopup"

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_testobj = "LODy_test" createVehicle [0,0,0];

_testobj setpos [(getpos player select 0),(getpos player select 1), ((getpos player select 2)+50)];

while {true} do {

_Pa = getpos _testobj;

_Pb = getpos player;

_Pab = [(_Pb select 0 - _Pa select 0), (_Pb select 1 - _Pa select 1),(_Pb select 2 - _Pa select 2)];

_testobj setVectorUp _Pab;

sleep 0.1;

};

on your player put nil = this execvm "weirdstuff.sqf"

take a ride around it with a heli tounge2.gif

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×