Collision woes
Blitz3D Forums/Blitz3D Programming/Collision woes
| ||
Okay, I've just started to use blitz collisions and I know I'm not using them correctly! I'm cycling through entities using countcollisions and seeing if anything's hit it. Obviously this can't be the correct way of doing it, so how does one get blitz to report what's been hit and by what? For example, for n=0 to max_shots blah blah blah c=CountCollisions(shot(n)) If c>0 for nn=0 to max_objects c=CountCollisions(Object_mesh(nn)) if c>0 And object_health(nn)>0 "object nn has been hit by shot n" endif next endif next This works fine, however, it just seems to be a painfully bad way of doing it! Suggestions would be appreciated! |
| ||
you can use the command collisionEntity(entity, index) to find out what object collided with each collision. Would be easier to do if you used types though :) for i=1 to countcollisions(shot(n)) for nn=0 to maxObjects if collisionEntity(shot(n),i)=object_mesh(nn) ;do the health stuff endif next next If you used types you could use the object and handle commands to get rid of the loop in the middle (the nn one) and get access to the object directly which would obviously cut out a lot of checking |
| ||
Yeah, I agree |
| ||
EDIT : [Oops didn't realise this was 3 years old] |
| ||
I'm not sure what the point of the "yeah, I agree" comment was but this post is 3 years old. I think Rob may have found a solution by now. |