Liberty Unleashed
Scripting => Script Help => Topic started by: Theremin on October 07, 2015, 09:46:16 pm
-
How to use ScreenPosToWorld? It either returns false or crashes my client. I saw a fourth parameter has been added in 0.1.0.15 update:
Scripting - Added a depth parameter to ScreenPosToWorld (client) - ScreenPosToWorld( float x, float y, float depth ), ScreenPosToWorld( Vector3 pos, float depth )
then Vortrex wrote something about the fact that it wasn't working:
ScreenPosToWorld is now not working.
It returns an instance in Vector form like it should, but ...
The vector is composed of "1.#R 1.#R 1.R"
Each object in the instance is "1.#QNAN"
It should be noted that typeof returns Vector, but its unusable.
Can somebody provide a working example?
-
It works weird, but:
function onScriptLoad()
{
ShowMouseCursor(true);
fDepth <- 10.0;
}
function onClientMouseClick(button, down, x, y)
{
if (down)
{
local pos = ScreenPosToWorld(VectorScreen(x, y), fDepth);
CallServerFunc(YOUR_PATH_HERE, "CreateObject2", 1344, pos.x, pos.y, pos.z);
}
}RegisterRemoteFunc("CreateObject2");
function CreateObject2(model, x, y, z) { CreateObject(model, Vector(x,y,z)); } //CallServerFunc doesn't work w/ Vector class, no idea why