Author Topic: Player Position relative to direction/vector  (Read 1016 times)

I'm trying to establish an XYZ coordinate area around a player that changes relative to the direction they are facing.

Basically, the default XYZ stays the same regardless of the direction you are looking in
I need three variables, XYZ, that change based on the direction you are facing. Basically when you return the %pos that a bullet hits a player object, I want it so that if I shoot the left arm, it will register the same as if the player is facing a different direction and the left arm is shot.

XYZ axis, with Z always pointing in the yaw();

Essentially create a fake axis/plane that covers the entire front collision of the player, and make that plane's perpendicular always be equal to the player's yaw();



with that I can get the coordinates on the plane and return all the values
« Last Edit: November 17, 2015, 06:48:07 PM by Path »

Code: [Select]
function player::findVectorHitSide(%pl,%o)
{
%o_fvec = vectorNormalize(%o.initialVelocity);
%o_pos = %o.getPosition();

%p_fvec = %pl.getForwardVector();
%p_pos = %pl.getWorldBoxCenter();
%p_turn = vectorDot(-getWord(%p_fvec,1) SPC getWord(%p_fvec,0) SPC 0,%o_fvec)*-1;

%c_pos = vectorSub(%p_pos,%o_pos);
}
this is all I got, if someone knows how to scew a vector collision you can use %p_turn (bounds [-1,1]) to scew the collision of the bullet (%o)

This resource might help you: http://forum.blockland.us/index.php?topic=270070

In addition, this is a similar problem to this topic: http://forum.blockland.us/index.php?topic=286014.0 only you are looking to do the reverse. You could in theory do the reverse of the solution I posted, and that should solve your problem.

This resource might help you: http://forum.blockland.us/index.php?topic=270070

In addition, this is a similar problem to this topic: http://forum.blockland.us/index.php?topic=286014.0 only you are looking to do the reverse. You could in theory do the reverse of the solution I posted, and that should solve your problem.
Thanks for the help. Zeblote was able to provide the easiest and most effective solution however. Posted here:

Code: [Select]
%t = %obj.getTransform();
        %prPos = getWords(%position,0,2);
        %plPos = getWords(%t,0,2);
        %final = matrixmulvector("0 0 0" SPC getwords(%t,3,5) SPC -getword(%t,6), vectorsub(%plPos, %prPos));