Since I can't seem to use setfacing(float); outside of a onspawn script, or assign it a AssignCommand - so I believe I'm stuck with SetFacingPoint(vector).
That being said..
oPC
oNPC
How do I get oNPC to face the same direction as oPC (0NPC's back is facing the oPC) WITHOUT creating a waypoint or object in which to direct it to.
As a Vector is an x,y,z - how do I get the oPC's vector to the oNPC's Vector to figure out what the Vector will be 'behind' the NPC (as the 'front' is the Vector of the PC)
Might be more work then it's worth, just to prevent putting down a waypoint behind the NPC and using that for the vector.
Setfacing and Vectors
Moderators: Moderator, Developer, DM
-
LordLP
- Posts: 213
- Joined: Wed Nov 10, 2010 5:01 am
Setfacing and Vectors
Arcon Anatox - Councilor of the Silver Shield
Lilly Underburrow - Not much other then scared
Lilly Underburrow - Not much other then scared
-
Duster47
- Retired Staff
- Posts: 3727
- Joined: Mon Nov 16, 2009 7:57 pm
- Location: Florida, USA
Re: Setfacing and Vectors
Did you try: location lPC = GetLocation(oPC); ? That is a little L at the beginning.
There is a "facing" or "heading" angle too; 0-360 (degrees) either clockwise or CCS, +/-. Use "float fPC = GetFacing(oPC);" You might need to toss in a float equation to get the opposite direction from one heading, - 180 (deg). Zero deg is East.
There are AngleToVector and VectorToAngle functions that may be useful too.
There is a "facing" or "heading" angle too; 0-360 (degrees) either clockwise or CCS, +/-. Use "float fPC = GetFacing(oPC);" You might need to toss in a float equation to get the opposite direction from one heading, - 180 (deg). Zero deg is East.
There are AngleToVector and VectorToAngle functions that may be useful too.
PC1 = Nerys, Emissary and Skald of the Greyfox tribe, last seen roaming north near Secomber
PC2 = Valqis Sanejmeh; far away cartographer, Oracle of Nut at chaltin QulDaq, former navigator of the Sea Seeker, Reader of Candlekeep and sometime performer.
PC2 = Valqis Sanejmeh; far away cartographer, Oracle of Nut at chaltin QulDaq, former navigator of the Sea Seeker, Reader of Candlekeep and sometime performer.
-
gedweyignasia
- Custom Content
- Posts: 1353
- Joined: Sat Nov 23, 2013 11:27 pm
- Location: EST/UTC-4
Re: Setfacing and Vectors
Get the facing of oNPC, turn it into a vector (there should be a function for that), add that to oPC's position, and face that point.
-
LordLP
- Posts: 213
- Joined: Wed Nov 10, 2010 5:01 am
Re: Setfacing and Vectors
I was wrong, you can AssignCommand to SetFacing.. so you guys are correct, that'll work.
void main()
{
object oModel = GetObjectByTag("NPC");
object oPC = GetPCSpeaker();
float fPC = GetFacing(oPC);
AssignCommand(oModel, SetFacing(fPC,1));
}
Wrote up:
float fPC = GetFacing(oPC);
float fSub = (fPC - 180.00);
int iMath = FloatToInt(fSub);
float fFace;
if (iMath < 0)
fFace = (fSub + 360);
else if (iMath > 0)
fFace = fSub;
AssignCommand(oModel, SetFacing(fFace ,1));
But NPC faces PC - so NPC rotates to face 180 degrees from PC's current facing.. he ends up.. right where he already is. Sorry I'm a moron. Got it working though, thanks!
void main()
{
object oModel = GetObjectByTag("NPC");
object oPC = GetPCSpeaker();
float fPC = GetFacing(oPC);
AssignCommand(oModel, SetFacing(fPC,1));
}
Wrote up:
float fPC = GetFacing(oPC);
float fSub = (fPC - 180.00);
int iMath = FloatToInt(fSub);
float fFace;
if (iMath < 0)
fFace = (fSub + 360);
else if (iMath > 0)
fFace = fSub;
AssignCommand(oModel, SetFacing(fFace ,1));
But NPC faces PC - so NPC rotates to face 180 degrees from PC's current facing.. he ends up.. right where he already is. Sorry I'm a moron. Got it working though, thanks!
Arcon Anatox - Councilor of the Silver Shield
Lilly Underburrow - Not much other then scared
Lilly Underburrow - Not much other then scared