Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Two Questions
Two Questions
2004-08-31, 4:43 AM #1
First of all, is there anyway to either calculate a vector between two points (in a Cog) or, more simply, just get the xyz coordinates for a thing?

Second: Is there any way to get the direction in which the player is looking?

Any help is appreciated!

------------------
"If I had a dollar for every time I had sixty cents, I would be Canada."
"Should slice indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration."
"I like the concept of people, but people ruin it."
"It has come to my attention that some of you have thumb-drives. They are cool."
--@%
Ban Jin!
Nobody really needs work when you have awesome. - xhuxus
2004-08-31, 5:06 AM #2
I may be wrong, but I usally use this code, based on *_Seifer_*'s code;

veldif=VectorSub(GetThingVel(projectile), GetThingVel(target));
speed=VectorLen(veldif);
distance=VectorDist(GetThingPos(target), GetThingPos(projectile));
time=distance / speed;
moved=VectorScale(GetThingVel(target), time);
meetpos=VectorAdd(GetThingPos(target), moved);

lvec=VectorNorm(VectorSub(meetpos, GetThingPos(projectile)));
SetThingLook(projectile, lvec);
projspeed=VectorLen(GetThingVel(projectile));
SetThingVel(projectile, VectorScale(lvec, projspeed));

Something like that.......I dont know if that helps or not...


Arden Lyn



[This message has been edited by Arden Lyn (edited August 31, 2004).]
2004-08-31, 6:33 AM #3
vector between two points, if I understand what you mean, should be:
resultVector = VectorSub(vector, vector);

xyz coordinates for a thing:
resultVector = GetThingPos(thing);

getting (true) direction in which the player is looking:
dummy = FireProjectile(player, lookTemplate, -1, -1, '0 0 0', '0 0 0', 0, 0x2, 0, 0);
resultVector = GetThingLVec(dummy);
DestroyThing(dummy);
a good lookTemplate is +punch

QM

[This message has been edited by Quib Mask (edited August 31, 2004).]
2004-08-31, 10:49 AM #4
Well, Quib's got you covered for getting a thing's position and getting the player's lookvector, and likely getting the vector between two points...
But, just in case, if by "vector between two points" you were looking for the midpoint between the two points (which is what I initially thought you wanted), you could use "VectorScale(VectorAdd(Vector1, Vector2), 0.5);"

------------------
nytfyre m0d || f33l t3h p0w3r || t3h l0st c0gz || OMF > *
May the mass times acceleration be with you.
2004-08-31, 1:07 PM #5
^ What he said ^
2004-08-31, 2:50 PM #6
Im pretty sure a GetThingPos(thing); will return a thing's x,y,z position. (the center of the thing)

------------------
My ^^eMail address^^ is expired!!
This is retarded, and I mean drooling at the mouth
2004-08-31, 7:21 PM #7
What kind of value will GetThingPos() return?

------------------
"If I had a dollar for every time I had sixty cents, I would be Canada."
"Should slice indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration."
"I like the concept of people, but people ruin it."
"It has come to my attention that some of you have thumb-drives. They are cool."
--@%
Ban Jin!
Nobody really needs work when you have awesome. - xhuxus
2004-08-31, 8:03 PM #8
Quote:
<font face="Verdana, Arial" size="2">What kind of value will GetThingPos() return?</font>

A vector.

QM
2004-08-31, 10:13 PM #9
Thanks everyone, especially you Quib. The code for getting the direction the player is looking worked, and now I've got everything working. Thanks a lot!

------------------
"If I had a dollar for every time I had sixty cents, I would be Canada."
"Should slice indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration."
"I like the concept of people, but people ruin it."
"It has come to my attention that some of you have thumb-drives. They are cool."
--@%
Ban Jin!
Nobody really needs work when you have awesome. - xhuxus

↑ Up to the top!