entity or linepick for bullet?

Blitz3D Forums/Blitz3D Programming/entity or linepick for bullet?

slenkar(Posted 2004) [#1]
I have some guns that are sposed to fire at enemies only (A.I.)
I am using linepicks for a laser style gun and entities as bullets for other guns.
The other guns have to use entitypick to see if there is an enemy in front of it

Is there any way of seeing if there is an enemy in front of an object (as opposed to an ally) apart from entitypick?


Beaker(Posted 2004) [#2]
EntityCollided() ?


slenkar(Posted 2004) [#3]
you mean set up inviible mesh's and test for colliion?


Beaker(Posted 2004) [#4]
I don't know what I meant, I was tired. :)

And today I'm not sure what you mean. The answer is probably "no".


AntonyWells(Posted 2004) [#5]
A basic way would be,

Entity1 = say player entity, lookFor=enemey entity. Fov =field of view.(I.45= 45 degress left and 45 degrees right. Not totaled)

so if los(myPlayer,Enemy,45)=true, enemey is in front if player.

Throw in a simple distance check, and you proper line of sight.(I.e it narrows the closer to the enity you get)..just think metal gear solid..the cones on radar, that shape. That's what this does basically.

function los(entity1,lookFor,fov=45,maxRange#=10)
  if entityDistance(entity1,lookFor)>maxRange return 
  dx=entityX(lookf)-entityX(entity1)
  dz=entityZ(lookf)-entityZ(entity1)
  ang#=atan2(dz,dx)
 if ang<0 ang=ang+360
  ad=angDif(ang,entityYaw(entity1) 
  if abs(ad)<fov return true 
end function

function angDif(ang1,ang2)
   if ang1>ang2
        d1=ang1-ang2
        d2=(360-ang1)+ang2
   else
        d1=ang2-ang1
        d2=(360-ang2)+ang1
   endif   
   if d1>d2 return d2 else return d1
end function



jfk EO-11110(Posted 2004) [#6]
I would use linepicks for distances less than 30 Meters. Using a Pistol, the bullets velocity will be around 300 Meters/s, so 30 Meters would take 1/10s. It wouldn't be obvious when you trigger the impact immediately, without the correct delay. Ammunition like 9mm, .45ACP, .22, .38 etc. is usually that fast. Rifle rounds may be faster. Eg. .308 winchester can be up to mach 2.5, around 800m/s. So when a sniper shoots from 1500 Meters distance, the bullet needs about one second until it hits the target. Thus for long distances (usually Rifles) you should probably use an autonomous bullet-entity.


Neo Genesis10(Posted 2004) [#7]
LinePick is the faster method of the two as it has limited range. EntityPick is much slower, but also has unlimited range which is useful for arcadey shooters.

For realism, you could have the gun actually fire a bullet which you could then check for collisions. You could also act upon the bullet with things like gravity and wind drag so that the player needs to think more before shooting.


slenkar(Posted 2004) [#8]
Is the cost of creating a bullet entity greater than doing a line pick of 100 meters?

The game is in space so wind resistance wont matter.