LASER Particle [C-SCRIPT]

Posted By: 3run

LASER Particle [C-SCRIPT] - 08/07/09 18:28

Hello. Can any one please give me an example of laser (I whant it for aiming in 3rd person shooter), that will start from defined vertex on gun and will collide with models and level blocks (woun't go through them).
Posted By: sebbi91

Re: LASER Particle [C-SCRIPT] - 08/07/09 18:44

no problem I would suggest to you the Laserweapon from the ratsoft "waffentutorial"
But its german!

http://www.rat-soft.de/dload/Waffentutorial.pdf

look at:"Energiewaffen" at page 26,27 and 28
it shows you an thunderlike weapon that burns !
don't know if this is what your looking for,but i think it could be easy modify!
Posted By: Rei_Ayanami

Re: LASER Particle [C-SCRIPT] - 08/07/09 18:46

Yeah this tutorial is great

@sebbi warum schreibst du nciht gleich in deutsch wenn du ein deutsches tutorial gibst wink
Posted By: sebbi91

Re: LASER Particle [C-SCRIPT] - 08/07/09 18:58

ich glaub er spricht leider kein deutsch!^^
ist meiner Meinung nach aber eins der besten Tutorials überhaubt!
Eine englische Variante wäre vieleicht nicht schlecht ^^

Posted By: 3run

Re: LASER Particle [C-SCRIPT] - 08/07/09 20:33

The problem is, that I do not know german frown And I alredy have this tutorial. I do not need lasergun... only laser for aiming!
Posted By: jigalypuff

Re: LASER Particle [C-SCRIPT] - 08/07/09 22:08

Would one of our german members be good enough to translate this?
Posted By: Ayumi

Re: LASER Particle [C-SCRIPT] - 08/08/09 00:28

Maybe;)
Give me some more time and i will translate it.
Posted By: 3run

Re: LASER Particle [C-SCRIPT] - 08/08/09 09:44

That will be just great! smile But what about a laser particle for now?! I realy need it...
Posted By: Xarthor

Re: LASER Particle [C-SCRIPT] - 08/08/09 10:03

The following code assumes that the direction of the weapon is the same as the default view's (camera).
Furthermore you need a small bitmap which is used for your laser beam:
Code:
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;
	
	while(laserAim_status)
	{
		// Assumption: laser_pos is a vector which represents the current position
		// of the laser beam start
		
		vec_set(temp,vector(10000,0,0)); // length of your laser beam
		vec_rotate(temp,camera.pan);
		
		effect(effect_LaserAim,1,laser_pos,temp);
		
		wait(1);
	}
}



NOTE: not tested, not sure if it works
Posted By: alibaba

Re: LASER Particle [C-SCRIPT] - 08/08/09 10:06

use the draw_line3d funcvtion. it makes a laser . read in the manual . everything is tghere explained.

EDIT: oh sorry i´ve overlooked the [c-script] . then don´t use my way. use the ones above me.
Posted By: 3run

Re: LASER Particle [C-SCRIPT] - 08/08/09 12:36

Looks good smile Thank you bro! But some questions... laser passes through the models and level blocks, how to fix that? And one more question, how to add "effect_LaserAim" to the vertex on model? So it will start from vertex on gun, I need to use vec_for_vertex I think... but how?
Posted By: Xarthor

Re: LASER Particle [C-SCRIPT] - 08/08/09 12:44

Alright, I changed some stuff, make sure to look at the comments:
Code:
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);
	}
}


Posted By: 3run

Re: LASER Particle [C-SCRIPT] - 08/08/09 13:09

Thank you Xarthor! It works but it still passes through the models and level blocks frown
Posted By: 3run

Re: LASER Particle [C-SCRIPT] - 08/08/09 14:36

Some bugs... laser is aiming to the center of the screen only when I'm looking to level blocks or when I'm inside the room, when I go outside laser aims to the right side... frown Do not know what to do..
Posted By: Xarthor

Re: LASER Particle [C-SCRIPT] - 08/08/09 15:20

Well the code snippet I provided takes the camera angle and displays a particle beam into that direction.
So if you work on a 3rd person shooter this might not be the case.
In this case you would have to find another way to calculate the direction of the laser.
So as long as you don't give more information about the environment in which this laser is supposed to work, I cannot help you any further.
Posted By: Ayumi

Re: LASER Particle [C-SCRIPT] - 08/08/09 16:29

ssooo,
fertig;)

->looks here:Waffentut_eng
http://www.megaupload.com/?d=W8DJZ6G1

-> or in my signature
Posted By: 3run

Re: LASER Particle [C-SCRIPT] - 08/08/09 18:57

Thank you man! Thank you for that great work you'v done!!!! smile Downloading now)) Xarthor I'm making 3rd person shooter, camera in on the players shoulder. All I whant is to make laser start from vertex on players gun and point the way straight... just straight. Not to the screen center. And how to make it do not pass models and level geometry?
Posted By: jigalypuff

Re: LASER Particle [C-SCRIPT] - 08/08/09 19:06

Thank you ayumi this is very decent of you smile
Should i get the chance i will return the favour smile
Posted By: Xarthor

Re: LASER Particle [C-SCRIPT] - 08/09/09 08:08

@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:
Code:
...
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);
...


© 2024 lite-C Forums