|
0 registered members (),
631
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Drag and Drop object
[Re: fusukery]
#128622
05/08/07 14:31
05/08/07 14:31
|
Joined: May 2004
Posts: 1,510 Denmark
Claus_N
Serious User
|
Serious User
Joined: May 2004
Posts: 1,510
Denmark
|
You need to use vec_for_screen to convert mouse (2D) coordinates to world (3D) coordinates. Code:
temp.x = mouse_pos.x; temp.y = mouse_pos.y; temp.z = YOUR_DISTANCE; // Depth
How you should compute the depth, depends on where you want the object to be. A c_trace could be used, as an example. Have a look at the RPG Movement code in AUM34, that might be what you need.
|
|
|
Re: Drag and Drop object
[Re: Claus_N]
#128623
05/08/07 15:05
05/08/07 15:05
|
Joined: Mar 2007
Posts: 776 Poor village - Poland ;)
tompo
User
|
User
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
|
in entity function: my.enable_mouse = on;
then loop if(event_type == event_mouse) //touch by mouse { while(mouse_left == 1){dragging me;} }
to keep object on ground and calculate angle from camera to mouse poniter in 3D world look at my click & go script
Never say never.
|
|
|
Re: Drag and Drop object
[Re: fusukery]
#128628
05/09/07 07:18
05/09/07 07:18
|
Joined: May 2004
Posts: 1,510 Denmark
Claus_N
Serious User
|
Serious User
Joined: May 2004
Posts: 1,510
Denmark
|
I works for me... Did you make the changes I posted above? Here's the full code again, which worked for me: Code:
function drag_event { my.red=255;//as long u drag it my.green=0;//it is colored red my.blue=0;//maybe u can do it also by event_touch while(mouse_left) { proc_late(); temp.x = mouse_pos.x; temp.y = mouse_pos.y; temp.z = 5000;//maybe more? O_o target.x = mouse_pos.x; target.y = mouse_pos.y; target.z = 0; vec_for_screen(temp,camera); vec_for_screen(target,camera); c_trace(target,temp,ignore_me + use_box); vec_Set(my.x,target.x); wait(1); } my.red=255; my.green=255; my.blue=255; } action drag_me { my.enable_click = on; my.event= drag_event; }
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|