Where _six normally goes the trig route with his solutions to problems like this, I myself find it easier to get my solution using vectors. Do not get me wrong here, there is nothing wrong with the trig solution given by _six, this is just another way to solve the same problem.
here is Six's code converted to a vector style.
vector vPos = GetPosition(oPC);
float fFacing = GetFacing(oPC);
vector vFacing = AngleToVector(fFacing );
float fDistAway = 1.0f;
vPos += vFacing * fDistAway;
object oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "thing", Location(GetArea(oPC), vPos, fFacing));
*********
A vector is a set of cordinats that defines a direction and a magnitude.
All the code segment does is take the facing of the PC and turn it into a vector. adjusts the magnitude of the vector by multiplying it by the distance. then added it to the PC's postion.to get the spawn point.
*******
@henesua; I do not like to use the "x0_i0_position" include. The first time I used it I found it had a bug in the function I was trying to use. I do not remember what the function was at the moment just that it did not return the desired results. I have not used the include since. Just a warning, If you use it a lot make sure you fully test your results.
Modifié par Lightfoot8, 17 juillet 2011 - 12:41 .