Would you mind elaborating a bit?
This is my function (the raycast bit anyways)
-- Casts a ray to check whether or not the enemy tanks have a clear firing path function ETfire( self, user\_tank ) EDray = physics.rayCast( self.x, self.y, user\_tank.x, user\_tank.y, "sorted" ) local hitFirst = EDray[1] local hitX, hitY = hitFirst.position.x, hitFirst.position.y if EDray then -- There's at least one hit. print( "Hit count: " .. tostring( #EDray ) ) -- Output all the results. for i,v in ipairs(EDray) do print( "Hit: ", i, v.object.class, " Position: ", v.position.x, v.position.y ) end print( "The first object hit is: ", EDray[1].object.class ) else -- There's no hit. end if ( EDray[1].object.class == "PlayerTank" or EDray[1].object.class == "Uturret" or EDray[1].object.class == "bullet") then print("PlayerTank in range! Fire!") timer.performWithDelay(40, function() ShootEnemyBullet( self, user\_tank ) end, 1) --- ShootEnemyBullet function and bullet code --- end
I guess I’m just confused on how to remove an object from the hit list…
According to the docs, when a ray is cast it returns an array of the objects hit - which in my case I’m assuming is EDray - and I’m guessing I’d just do something like if EDray.object.class == “Radar” then – remove object from hit list –
Would I just use table.remove(EDray, 1) or is there a different way I should do it?
– Sorry for my lack of knowledge, I’ve only just recently optimized my code to make use of tables. –
-Saer