Blockland Forums > Modification Help

Position Behind a vehicle

Pages: (1/2) > >>

Brian Smithers:

How do I get the position behind a vehicle?
Help appreciated!

Destiny/Zack0Wack0:


--- Code: ---function getObjectBackPosition(%obj) {
%box = %obj.getWorldBox();
%max = getWords(%box, 3, 6);
%min = getWords(%box, 0, 2);
%size = vectorSub(%max, %min);
%sizeX = getWord(%size, 0);
%sizeY = getWord(%size, 1);
%sizeZ = getWord(%size, 2);
%forward = %obj.getForwardVector();
%scaleX = getWord(%forward, 0) * 0.5;
%scaleY = getWord(%forward, 1) * 0.5;
%scaleZ = getWord(%forward, 2) * 0.5;

return vectorSub(getWords(%obj.getTransform(), 0, 2), %sizeX * %scaleX SPC %sizeY * %scaleY SPC %sizeZ * %scaleZ);
}

--- End code ---

I may be overcomplicating it, but it works.

Xalos:

getWorldBox isn't 1-to-1 scale, I know from experience.


Plus "behind" would be relative to the vehicle, so you should use getEyeVector instead of getForwardVector.

Brian Smithers:


--- Quote from: Xalos on January 15, 2012, 01:48:40 AM ---getWorldBox isn't 1-to-1 scale, I know from experience.


Plus "behind" would be relative to the vehicle, so you should use getEyeVector instead of getForwardVector.

--- End quote ---
doesn't getForwardVector() return the front of the collision box?

Port:


--- Quote from: Brian Smithers on January 15, 2012, 02:08:31 AM ---doesn't getForwardVector() return the front of the collision box?

--- End quote ---

getForwardVector() returns the normalized vector that the object is facing. It has nothing to do with positions.

Pages: (1/2) > >>

Go to full version