I'm not using the quote code, however I am using exactly the same code for the vec_for_screen part, and that gives me the same deviation I'm currently dealing with.

If you click the object using this action you will be able to move it while it's under your mouse cursor, however, it's position will not stay exactly underneath the mouse cursor, instead, it has a deviation. The further you move the object away from the center, the bigger the deviation. (even if optical illusion, I don't want it to have this deviation...)

Code:
function pick_or_drop()
{
wait (1);
my.skill1 += 1;
if ((my.skill1 % 2) == 1) // clicked the object?
{
while (mouse_left == on) {wait (1);}
while (mouse_left == off) // move the object until the player presses the mouse button again
{
temp.x = pointer.x;
temp.y = pointer.y;
temp.z = 200; // move the object 200 quants below the camera, play with this value
vec_for_screen(temp.x, camera);
my.x = temp.x;
my.y = temp.y;
my.z = temp.z;
wait (1);
}
}
else // drop the object
{
vec_set (temp.x, my.x);
temp.z -= 3000;
trace_mode = ignore_me + ignore_sprites + ignore_models + use_box;
my.z -= trace (my.pos, temp); // place the object on the ground
}
}

action click_and_move
{
my.skill1 = 0;
my.enable_click = on;
my.event = pick_or_drop;
}



How can I fix this? I'm quite lost on how to solve this, especially because I don't quite get the problem. It should have the right coordinates because vec_for_screen took care of that, but apparently it doesn't quite.

The thing is, I'm trying to attach a particle effect to my mouse cursor using an object in 3D with a particle function attached. Thing is, the particle effect doesn't follow the cursor accurately, instead it has a huge deviation. I'm a total loss here, I've already tried adding certain values, but that only made it worse, probably because I do not quite understand the nature of this problem.

(by the way, "doing it the other way around" doesn't give deviations at all; meaning from 2D to 3D position like this;

Code:

bmap my_pcx = <my.pcx>;
panel my_pan
{
bmap = my_pcx;
layer = 15;
flags = overlay, refresh, visible;
}
function highlight_me()
{
var temporary;
while (1)
{
vec_set (temporary, my.x);
vec_to_screen (temporary, camera);
my_pan.pos_x = temporary.x;
my_pan.pos_y = temporary.y;
wait (1);
}
}
action my_entity
{
highlight_me(); // attach the panel to the entity
// put the rest of the code for your entity here
}


)



Edit: In the meantime I've got it working using a work-around, but any thoughts on this problem are still very welcome ..

Cheers

Last edited by PHeMoX; 06/19/07 06:28.

PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software