Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 12,400 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
bullets #247321
01/20/09 06:27
01/20/09 06:27
Joined: Oct 2008
Posts: 67
pewpew Offline OP
Junior Member
pewpew  Offline OP
Junior Member

Joined: Oct 2008
Posts: 67
i've followed the help section but i cant seem to get the bullets i fire from my vehicle to disappear after they hit an object (like a wall in a level etc.)

they just freeze on the object. i am using c_move to propell the bullet from the gun.

how do you detect a collision and destroy the bullet?


HURRR DERP DERP DEERRPP HURR
Re: bullets [Re: pewpew] #247336
01/20/09 09:24
01/20/09 09:24
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
use a skill (or flag) of the bullet to check if its alive or not.
In the event function set this skill (or flag) to "dead". Furthermore you use this skill (or flag) as condition for the while loop of it, which is then skipped when the bullet is "dead" and after the while loop you remove the bullet.

lite-C Example using a skill:
Code:
#define health skill1

function bullet_event()
{
  if(event_type == EVENT_BLOCK || event_type == EVENT_ENTITY)
  {
    my.health = 0;
  }
}

action bullet_act()
{
  my.health = 1;
  
  while(my.health)
  {
    // do the c_move stuff in here
  }

  wait(1);
  ent_remove(me);
}

note: Not tested code!

Re: bullets [Re: Xarthor] #247339
01/20/09 09:51
01/20/09 09:51
Joined: Oct 2008
Posts: 67
pewpew Offline OP
Junior Member
pewpew  Offline OP
Junior Member

Joined: Oct 2008
Posts: 67
Code:
//fire primary weapon
action game_fire_primary()
{
	e_bullet = ent_create("models\\bullet1.mdl", tank_turret.x, game_fire_bullet);
	
	vec_set(e_bullet.pan, tank_turret.pan);
	
}

//bullet behaviour
action game_fire_bullet()
{
	my.skill1 = 1;
	
	while(my.skill1)
	{
		c_move(me, vector(0,40,0), nullvector, IGNORE_FLAG2);
		game_bullet_collide();
		wait(1);
	}
	
	wait(1);
	ent_remove(me);

}

//bullet destruction
function game_bullet_collide()
{
	if(event_type == EVENT_BLOCK || event_type == EVENT_ENTITY)
	{
		me.skill1 = 0;
		draw_text("collision", settings.screen.x / 2, settings.screen.y /2, vector(255,0,0));
	}
		
}


it doesnt seem to work?
the bullet just seems to stop on the wall or entities....?
im not sure what im doing wrong smirk


HURRR DERP DERP DEERRPP HURR
Re: bullets [Re: pewpew] #247342
01/20/09 10:16
01/20/09 10:16
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
add my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY);
my.event = game_bullet_collide;
to action game_fire_bullet

dam i forgot the event

Last edited by flits; 01/20/09 10:20.

"empty"
Re: bullets [Re: pewpew] #247343
01/20/09 10:18
01/20/09 10:18
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
uhps I forgot that you need to set the events.
Code:

//bullet destruction
function game_bullet_collide()
{
	if(event_type == EVENT_BLOCK || event_type == EVENT_ENTITY)
	{
		me.skill1 = 0;
	}
		
}

//bullet behaviour
action game_fire_bullet()
{
	my.skill1 = 1;

        my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY);
        my.event = game_bullet_collide;
	
	while(my.skill1)
	{
		c_move(me, vector(0,40,0), nullvector, IGNORE_FLAG2);
		wait(1);
	}
	
	wait(1);
	ent_remove(me);

}



you should also multiply your movement speed with time_step to get frame-rate independent movement

Re: bullets [Re: Xarthor] #247347
01/20/09 11:25
01/20/09 11:25
Joined: Oct 2008
Posts: 67
pewpew Offline OP
Junior Member
pewpew  Offline OP
Junior Member

Joined: Oct 2008
Posts: 67
perfect

thanks guys laugh


HURRR DERP DERP DEERRPP HURR

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1