|
|
Laser targeting
#123574
04/12/07 22:26
04/12/07 22:26
|
Joined: Mar 2007
Posts: 776 Poor village - Poland ;)
tompo
OP
User
|
OP
User
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
|
How to create a thin line from a gun to the target? Like gun's light? I understand that I have to trace from gun to target and I can do it. But now, how to create a line from gun x,y,z to target x,y,z?
Never say never.
|
|
|
Re: Laser targeting
[Re: nipx]
#123576
04/12/07 22:53
04/12/07 22:53
|
Joined: Mar 2007
Posts: 776 Poor village - Poland ;)
tompo
OP
User
|
OP
User
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
|
I know that but how?  and if You scaled a model he is scaled to both direction, not only from gun to target. Particles... you mean 100000000 particles ony by one to create a line?! It doesn't look like good (fast render) idea 
Never say never.
|
|
|
Re: Laser targeting
[Re: tompo]
#123577
04/12/07 23:08
04/12/07 23:08
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
For particles, it's simply one particle "streaked" between the two points...
For the entity, you can scale only one dimension. ex: my.scale_x = 10;
xXxGuitar511 - Programmer
|
|
|
Re: Laser targeting
[Re: xXxGuitar511]
#123578
04/12/07 23:26
04/12/07 23:26
|
Joined: Mar 2007
Posts: 776 Poor village - Poland ;)
tompo
OP
User
|
OP
User
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
|
Give me a code to streak between two ponits, please;) Of'course You can scale only my.scale_x but it's growing to both directions, to and from the emiter (gun). Or maybe I'm wrong.. so give me example script;)
Never say never.
|
|
|
Re: Laser targeting
[Re: tompo]
#123579
04/12/07 23:28
04/12/07 23:28
|
Joined: Dec 2005
Posts: 252 MyOwnKingdom
nipx
Member
|
Member
Joined: Dec 2005
Posts: 252
MyOwnKingdom
|
Quote:
Give me a code to streak between two ponits, please;)
-> my.streak=on; in your particle script.
give me a min for the scale_x...
nipx
1000 posts (! much ! fanfare !) congrat 
|
|
|
Re: Laser targeting
[Re: nipx]
#123580
04/12/07 23:43
04/12/07 23:43
|
Joined: Mar 2007
Posts: 776 Poor village - Poland ;)
tompo
OP
User
|
OP
User
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
|
I know my.streak =on function:) but how to make streak from vector1 to vector2 ?
I've made something like this, but doesn't look well:
function laser_fun { my.lifespan = 0; }
function laser_fun { my.bmap = sparkle_bmp; my.passable = off; my.beam = on; my.flare = on; my.bright = on; my.streak = on; my.transparent = on; my.alpha = 70; vec_add (my.vel_x, gun_pos); my.function = laser_fun; }
function laser_fire { while(mouse_left == 1) { effect(laser_fun,1,gun.pos,normal); wait(5); } }
function gun_fun { gun = me; while(1) { vec_diff(gun_pos,target.x,my.pos); //target is the result of trace wait(1); } } on_mouse_left laser_Fire;
Never say never.
|
|
|
Re: Laser targeting
[Re: tompo]
#123581
04/13/07 00:10
04/13/07 00:10
|
Joined: Dec 2005
Posts: 252 MyOwnKingdom
nipx
Member
|
Member
Joined: Dec 2005
Posts: 252
MyOwnKingdom
|
ok, try this: 1.set correct hull 2.get the original size 3.always look to the target 4.put in the middle (before you get the factor!) 5.get the factor to stretch 6.scale it with this factor ===>>> Code:
var originalSize; var distToTarget; var finalLength;
//wait for first BB wait(1);
//set correct hull c_setminmax(me);
//get the original size originalSize=my.max_x*2;
//look to target vec_set(temp, target.x); vec_sub(temp, my.x); vec_to_angle(my.pan, temp); //calculate distance distToTarget=vec_dist(my.x, target.x);
//place in the middle vec_set(temp, my.x); vec_sub(temp, target.x); vec_add(my.x, temp);
///**** not sure if this works. if not try this: ****/// //my.x+=target.x-my.x; //my.y+=target.y-my.y; //my.z+=target.z-my.z; //**** ****///
//calculate factor finalLength=distToTarget/originalSize; //scale the model my.scale_x=finalLength;
didnt really test this code, but could work  nipx
|
|
|
Re: Laser targeting
[Re: nipx]
#123582
04/13/07 06:36
04/13/07 06:36
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
Expert
|
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
for the particles, I have the code somewhere... (note: you need at least commercial for the streak effect to work) Code:
function delete_line() { if(my.alpha < my.skill_a && my.skill_c == 0) { my.alpha + = 20*time_step; } else { my.skill_c = 1; my.alpha - = 2*time_step; } }
function line_red() { my.bmap = red_line; my.move = off; //important! my.streak = on; my.alpha = 0; my.bright = on; my.transparent = on; my.size = .75; my.skill_a = 7; my.function = delete_line; }
//careful: the vectors you pass to this function have to be global vectors... function draw_red_line(&vectorfrom,&vectorto) { vec_diff(temp,vectorto,vectorfrom); effect(red_line,1,vectorfrom,temp); }
Hope it helps...
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
|