Jump to content
Sign in to follow this  
Alert23

Detect a bullet missing its target

Recommended Posts

Is it possible to somehow detect a bullet which misses a target or hits close to a target via eventhandler "fired"?

And would it be possible to check if a bullet will 100% hit a target? 

Share this post


Link to post
Share on other sites

I wouldn't see why it's not possible as long as you can get the actual projectile object, you would just need to compare its position to your targets position.

Share this post


Link to post
Share on other sites

 what i try to do is a bulletcam which should always be created only if you fired at a Soldier and be destroyed if target is hit, but sometimes even if the bulletcam is created the bullet misses its target because the target moves and then the bulletcam wont be deleted is there a way how i can immediately destroy the camera if target is missed or the bullet hits something other than a soldier?

slowMoCam = player addEventHandler ["Fired", {_this spawn {      

 	
BulletCam = _this spawn {            
   	if (cursorObject iskindOf "CAmanBase" && alive cursorObject) then {     
       	
	BulletEffect = ["ChromAberration", 200, [0.02, 0.02, true]] spawn {              
          	params ["_name", "_priority", "_effect"];              
			while {              
				pBhandle = ppEffectCreate [_name, _priority];              
				pBhandle < 0} do {              
				_priority = _priority + 1;};              
				pBhandle ppEffectEnable true;              
				pBhandle ppEffectAdjust _effect;              
				pBhandle ppEffectCommit 0.05;};           

		missile = _this select 6;
		cam = "camera" camCreate (position missile);             
		cam cameraEffect ["External", "Back"];          
		showCinemaBorder false;            	
	
	waitUntil {           
               if (isNull missile) exitWith {true};           
          		cam camSetTarget missile;           
          		cam camSetRelPos [0,-3,0];           
          		cam camCommit 0;           
          		setAccTime 0.07;           
          		false};  
 
	missile addEventHandler ["EpeContactStart", {       
           	params ["_object1", "_object2", "_selection1", "_selection2", "_force"];       
           	deleteVehicle missile;}];  
       
            waitUntil {!alive missile};               
         	pBhandle ppEffectAdjust [0,0,0];        
         	pBhandle ppEffectCommit 0.05;           
              	player cameraEffect ["terminate","back"];             
              	camDestroy cam;            
              	setAccTime 1;};   
		};                 
	

cursorObject addEventHandler ["Hit", {  _this spawn {      
        	params ["_unit", "_source", "_damage", "_instigator"];  
			if (_unit iskindOf "CAmanBase") then {         
				_unit setdammage 1;  
				deleteVehicle missile;       
				pBhandle ppEffectAdjust [0,0,0];        
				pBhandle ppEffectCommit 0.05; 
				player cameraEffect ["terminate","back"];             
				camDestroy cam;            
				setAccTime 1;};  
			};   
		}];        
	};
}];

 

Share this post


Link to post
Share on other sites

All you would need to do is obtain it's velocity or speed and once it has come either to a stop or slows down to a certain point then you can have it be deleted. This is why I mentioned having the object.

  • Like 2

Share this post


Link to post
Share on other sites
33 minutes ago, maihym said:

All you would need to do is obtain it's velocity or speed and once it has come either to a stop or slows down to a certain point then you can have it be deleted. This is why I mentioned having the object.

thank you this worked great just added this line and delete some other

waitUntil {speed missile < 1};
player cameraEffect ["terminate","back"];
camDestroy cam;

 

Share this post


Link to post
Share on other sites

but somehow if still target is missed and bullet hits a surface it can bounce and still fly.. i think its better to check when it first time hits an object then delete it, you know how to check this?

Share this post


Link to post
Share on other sites

Perhaps you could monitor distance between the bullet and the shooter and exit bulletcam as soon this distance becomes bigger than the distance between the shooter and the target, which usually means, the bullet passed/missed the target. Homing/manually controlled missiles may be an exception sometimes, I guess, but since it is about shooting at foot mobiles specifically, that shouldn't be a problem. 

  • Thanks 1

Share this post


Link to post
Share on other sites
2 hours ago, Alert23 said:

And would it be possible to check if a bullet will 100% hit a target? 

 

AFAIK no. You would need not only to calculate exact bullet's flight trajectory in advance (which, even if doable in exact manner somehow, may take considerable in this contex time), but also to know in advance, what the AI would do during the bullet flight (exact target movement and silhuette changes), not only targetted AI, but also other, that can block the bullet path.

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×