Ogniok
Member
|
Obtaining postion
Hi!
How to obtain a world position that main character(Players[0]) is looking on?
I'm using this code, but it isn't working:
Code:
Vec pos;
Vec dir;
PhysHit physHit;
ScreenToPosDir(Vec2(0, 0), pos, dir);
if(Physics.ray(pos, (pos + dir * D.viewRange()) - pos, &physHit))
{
LitSquad->soliders[0]().mustMoveTo(physHit.plane.pos);
[...]
Solider is moving to my position. Always. What's wrong?
Sorry for my english.
|
|
02-04-2011 08:37 PM |
|
Dandruff
Member
|
RE: Obtaining postion
try offsetting the position of pos to something higher then its legs.
pos -= Vec(0, 1, 0);
try LitSquad->soliders[0]().mustMoveTo(physHit.plane.pos - pos());
try just dir * D.viewRange() in the second parameter of Physics.ray
|
|
02-05-2011 08:24 AM |
|
Harry
Member
|
RE: Obtaining postion
Maybe physHit point on player first. Use callback to exclude him.
|
|
02-05-2011 01:51 PM |
|
Ogniok
Member
|
RE: Obtaining postion
Thanks. This is working for me:
Code:
if(Physics.ray(pos, dir * D.viewRange(), &physHit, ~IndexToFlag(AG_CONTROLLER)))
|
|
02-05-2011 04:07 PM |
|