view ent

Posted By: GaniX

view ent - 09/14/13 18:34

hi , i have a question :
if i use a view entity to make a coltshell of the gun . when i use a machinegun for example , i must declarate all of the coltshell or i can reuse the first original?
Code:
ENTITY*coltshell=
{
	type = "coltshell.mdl";
	
	flags2 = OVERLAY |PASSABLE;
 	layer = 0;
	scale_x = 1.5;
	scale_y = 1.5;
	scale_z = 1.5;
	x = 30;
	y = -6;
	z = -2;
}


function animate_gun()
{
...
	if (gun_percent<50)//no shot or coltshell in the air
	{
	coltshell.alpha = 0;
	coltshell.flags2 |= INVISIBLE |TRANSLUCENT;
	coltshell.tilt =  0;
	coltshell.y	  = -6;
	coltshell.z    = -2;		
	coltshell.x	  = 30;	
	coltshell.pan  =  0;
	
	}else{
		sonidodisp+=1;
	if(sonidodisp==1)snd_play(shot, 100, 0);// shoot or //coltshell in t air
		coltshell.flags2 |= SHOW; 
		coltshell.pan+=(2+random(20))*time_step;
		coltshell.tilt+=(2+random(20))*time_step;
		coltshell.y-=(1.7+random(1))*time_step;
		coltshell.z+=(1.7+random(1))*time_step;
 ...

Posted By: rayp

Re: view ent - 09/14/13 18:50

U mean u change the weapon and the coltshell changes with it ?
If so
Code:
ent_morph

should do the trick
Posted By: GaniX

Re: view ent - 09/16/13 16:14

tks for your help rayp.
but i try to do other thing.
when the player is shoot with a machinegun, the machinegun expulse multiples coltshell, its say i can see more of 1 coltshell in the air ,the question is: i need declarate all the coltshell like a new entitty or i can reuse the old entity.
Posted By: GaniX

Re: view ent - 09/18/13 19:51

i do the effect of the colltshell pulse using an animation in the med .
is any other way to do that?
Posted By: EpsiloN

Re: view ent - 09/19/13 07:46

Create a static shell for a bullet, without animations.
You can create more than one shell using
Code:
ent_createlayer(STRING* filename, var flags2, var layer)


Look for the function in the manual.
After creating the shell, give it a layer and position on the screen and animate it through script.
Add initial velocity upwards and right (for example) and then decrease the upwards velocity until a gravity effect is simulated.
If you want you can use world entities (ent_create) but then you have to make then spawn exactly at a specific point on the screen (possibly converting screen cordinates X,Y to world coordinates with a Z distance value).
This has the advantage that the shells can be left on the ground for the player to look at for a few seconds before fading away.

I hope this helps you.

PS.: vec_for_screen (convert screen coordinatess to world coordinatess) example
This isnt tested, but it should work. Write your own code for the animation after the comment line using c_move and a decreasing skill for z velocity...
Code:
function animate_shell()
{
    my.skill10 = 250; //lifespan
    while(my.skill10 > 0)
    {
      // animate it here
      // ...

      my.skill10 -= 1;
      wait(1);
    }
}

// In player action (if a mouse_left input)
    shell_spawn.x = 640; // Middle of resolution 1280x1024
    shell_spawn.y = 512;
    shell_spawn.z = 10; // Distance from screen
    vec_for_screen(shell_spawn.x,camera);
    ent_create("shell.mdl",shell_spawn.x,animate_shell);

Posted By: GaniX

Re: view ent - 10/02/13 23:27

hi epsilon; tks for help me.
i´d tried with some codes like your code of your up post , and others using vec to screen and others codes using rel_to_screen but i have not the result i´m looking for.
wath i want is to move a coltshell mdl in the screen monitor using xyz position relative to the view, and not to the world.
i found a solution using 5 different entities (ENTITY*a)and in the player code this. if mouse left ....b=ent_create_layer(...), a=ent_create_layer(.....) and then animate a.pan +=1 ...; and re use this entities coltshell .
any other way more easy to Make This and not Declarate five different entities?.

tks for your atention
© 2024 lite-C Forums