|
|
Drag entity at run time
#173516
12/18/07 08:34
12/18/07 08:34
|
Joined: Oct 2007
Posts: 85
harry3174
OP
Junior Member
|
OP
Junior Member
Joined: Oct 2007
Posts: 85
|
Hi I want to drag entity at run time. Can anybody give me command for drag entity ? Thanking you Alpa 
|
|
|
Re: Drag entity at run time
[Re: harry3174]
#173519
12/19/07 13:25
12/19/07 13:25
|
Joined: Aug 2005
Posts: 1,558 HK
vlau
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,558
HK
|
The link works, probably you need to register first http://www.filefront.com/Anyway, here is the part of the wdl : Code:
function nodeEvent() { if (event_type == event_release) { my.skin = 1; // original skin } if (event_type == event_touch) { my.skin = 2; // hilight skin } if (event_type == event_click) { my.skill13 = my.z; // store original z-pos. // drag node while(mouse_left) { my.skin = 2; my.skill10 = mouse_pos.x; // follow mouse x-pos my.skill11 = mouse_pos.y; // follow mouse y-pos my.skill12 = camera.z; // same as camera z-pos vec_for_screen(my.skill10,camera); // update to world pos my.x = my.skill10; my.y = my.skill11; my.z = my.skill12;
my.flag1 = on; // node has been moved, update offset. wait(1); } my.skin = 1; my.z = my.skill13; // reset z-pos } } action nodeLead { lead = my; my.passable = on; my.enable_touch = on; my.enable_release = on; my.enable_click = on; my.event = nodeEvent; }
|
|
|
Re: Drag entity at run time
[Re: harry3174]
#173521
12/25/07 04:12
12/25/07 04:12
|
Joined: Oct 2007
Posts: 85
harry3174
OP
Junior Member
|
OP
Junior Member
Joined: Oct 2007
Posts: 85
|
Marry Christmas
I have take earth.mdl as drag entity.assine drag action.Now i take other entity sp.mdl which is invisible when game start in wed and define ENTITY* sp; in script.I have this code in drag action.
if (vec_dist(sp.x,my.x) < 75) // play with 50 { my.INVISIBLE = on; sp.INVISIBLE = off; }
Its give me empty pointer error.Please help. here is full code
var video_mode = 8; var video_depth = 32;
var speed = 10; entity* lead; entity* node; entity* sp;
string snodeName; string snodeNo; var nodeNo = 0;
// NOTICE : // get next node // name your nodes in sequence in WED, such as // node_1, node_2, node_3 etc... /*function getNextNode() { nodeNo += 1; nodeNo = cycle(nodeNo,1,7); str_cpy(snodeName,"node_"); str_for_num(snodeNo,nodeNo); str_cat(snodeName,snodeNo); node = ent_for_name(snodeName); }*/
function main() { level_load("drag.wmb"); wait(2); // bird view vec_set(camera.z,vector(0,0,500)); // 2000 = camera z-pos camera.tilt = -90; mouse_mode = 1; mouse_range = 20000; while(1) { mouse_pos.x = mouse_cursor.x; mouse_pos.y = mouse_cursor.y; if (key_w){ camera.tilt += 2 * time_step; } if (key_s) { camera.tilt -= 2 * time_step; } if (key_a) { camera.pan += 2 * time_step; } if (key_d){ camera.pan -= 2 * time_step; } wait(1); } }
function drag() { if (event_type == event_release) { my.skin = 1; // original skin } if (event_type == event_touch) { my.skin = 1; // hilight skin } if (event_type == event_click) { my.skill13 = my.z; // store original z-pos. // drag while(mouse_left) { my.skin = 1; my.skill10 = mouse_pos.x; // follow mouse x-pos my.skill11 = mouse_pos.y; // follow mouse y-pos my.skill12 = camera.z; // same as camera z-pos vec_for_screen(my.skill10,camera); // update to world pos my.x = my.skill10; my.y = my.skill11; my.z = my.skill12; my.flag1 = on; // node has been moved, update offset. wait(1); } my.skin = 1; my.z = my.skill13; // reset z-pos } } action nodeLead { lead = my; my.passable = on; my.enable_touch = on; my.enable_release = on; my.enable_click = on; my.event = drag; if(vec_dist(sp.x,my.x) < 75) // play with 50 { my.INVISIBLE = on; } }
action sp_entity { Sp = my; my.INVISIBLE = On; // set(my,INVISIBLE); //giving syntex error }
|
|
|
Re: Drag entity at run time
[Re: harry3174]
#173522
12/25/07 06:04
12/25/07 06:04
|
Joined: Aug 2005
Posts: 1,558 HK
vlau
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,558
HK
|
Code:
action nodeLead {
// Ensure entity sp is load in the level // before access its pointer while (sp==NULL) {wait(1);}
lead = my; my.passable = on; my.enable_touch = on; my.enable_release = on; my.enable_click = on; my.event = drag;
if(vec_dist(sp.x,my.x) < 75) // play with 50 { my.INVISIBLE = on; } }
|
|
|
Re: Drag entity at run time
[Re: vlau]
#173523
12/27/07 04:25
12/27/07 04:25
|
Joined: Oct 2007
Posts: 85
harry3174
OP
Junior Member
|
OP
Junior Member
Joined: Oct 2007
Posts: 85
|
Thanks, Well i change priority.I put earth action as second action.So my empty error has gone. Actully i am trying snap entity(earth with sphere).when earth goes near to sp earth will invisible and sp will visible.In car action which condition you used, i put it in earth action.But nothing is happend.Please help.
var video_mode = 8; var video_depth = 32;
var speed = 10;
ENTITY* earth;
string snodeName; string snodeNo; var nodeNo = 0;
// NOTICE : // get next node // name your nodes in sequence in WED, such as /*function getNextNode() { nodeNo += 1; nodeNo = cycle(nodeNo,1,7); str_cpy(snodeName,"node_"); str_for_num(snodeNo,nodeNo); str_cat(snodeName,snodeNo); node = ent_for_name(snodeName); }*/
function main() { level_load("drag.wmb"); wait(2); // bird view vec_set(camera.z,vector(0,0,2000)); // 2000 = camera z-pos camera.tilt = -90; mouse_mode = 1; mouse_range = 10000; while(1) { mouse_pos.x = mouse_cursor.x; mouse_pos.y = mouse_cursor.y; if (key_w){ camera.tilt += 2 * time_step; } if (key_s) { camera.tilt -= 2 * time_step; } if (key_a) { camera.pan += 2 * time_step; } if (key_d){ camera.pan -= 2 * time_step; } wait(1); } }
function drag() { if (event_type == event_release) { my.skin = 1; // original skin } if (event_type == event_touch) { my.skin = 1; // hilight skin } if (event_type == event_click) { my.skill13 = my.z; // store original z-pos. // drag while(mouse_left) { my.skin = 1; my.skill10 = mouse_pos.x; // follow mouse x-pos my.skill11 = mouse_pos.y; // follow mouse y-pos my.skill12 = camera.z; // same as camera z-pos vec_for_screen(my.skill10,camera); // update to world pos my.x = my.skill10; my.y = my.skill11; my.z = my.skill12; my.flag1 = on; // node has been moved, update offset. wait(1); } my.skin = 1; my.z = my.skill13; // reset z-pos } } action nodeLead { earth = my; my.passable = on; my.enable_touch = on; my.enable_release = on; my.enable_click = on; my.event = drag; /*if (vec_dist(my.x,earth.x)< 50) // play with 50 { my.INVISIBLE = off; }*/ }
action sp_entity { // sp = my; my.INVISIBLE = On; if (vec_dist(my.x,earth.x)< 50) // play with 50 { earth.INVISIBLE = off; my.INVISIBLE = Off; }
}
|
|
|
Re: Drag entity at run time
[Re: harry3174]
#173524
12/27/07 09:36
12/27/07 09:36
|
Joined: Aug 2005
Posts: 1,558 HK
vlau
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,558
HK
|
It didn't work because the sp entity check the distance only once when it load into the level. You need to put the if statement inside a loop. Code:
action sp_entity { sp = my; my.INVISIBLE = On;
while(my) { if (vec_dist(my.x,earth.x)< 50) // play with 50 { earth.INVISIBLE = On; my.INVISIBLE = Off; } wait(1); } }
|
|
|
|