2 registered members (ozgur, degenerate_762),
1,495
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: LASER Particle [C-SCRIPT]
[Re: 3run]
#283564
08/08/09 12:44
08/08/09 12:44
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
Expert
|
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
Alright, I changed some stuff, make sure to look at the comments:
bmap laserAim_map = "myLaserAimBitmap.bmp";
var laserAim_status = 0;
function effect_LaserAim()
{
my.alpha = 60;
my.bmap = laserAim_map;
my.move = on;
my.bright = on;
my.beam = on; // if beam doesn't look good, try my.streak = on; instead
my.lifespan = 1;
}
function toggle_LaserAim()
{
laserAim_status = !laserAim_status;
var laser_pos[3];
while(laserAim_status)
{
// Assumption: laser_pos is a vector which represents the current position
// of the laser beam start
vec_for_vertex(laser_pos,gun_entity,123); // fill in the correct data here
vec_set(temp,vector(10000,0,0)); // length of your laser beam
vec_rotate(temp,camera.pan);
c_trace(laser_pos,temp,IGNORE_ME|IGNORE_PASSABLE);
vec_set(temp,target.x);
vec_sub(temp,laser_pos);
effect(effect_LaserAim,1,laser_pos,temp);
wait(1);
}
}
|
|
|
Re: LASER Particle [C-SCRIPT]
[Re: jigalypuff]
#283667
08/09/09 08:08
08/09/09 08:08
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
Expert
|
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
@3run: What you need is a second vertex or the angle of the gun itself. I would go with a second vertex to have two points to calculate the direction of the laser. Now if you have this you calculate the direction:
...
vec_for_vertex(pos_front,...); // starting position of the laser
vec_for_vertex(pos_back,...); // a vertex behind it but on the line of the laser
vec_set(temp,pos_front);
vec_sub(temp,pos_back);
// now temp is the difference and thus direction from pos_back to pos_front
// we now normalize it to a specific length
vec_normalize(temp,10000);
// now we add the pos_front vector to it to get the end vector
vec_add(temp,pos_front);
// now you trace from pos_front to temp
c_trace(pos_front,temp,IGNORE_PASSABLE);
...
|
|
|
|