Entitycollided
Blitz3D Forums/Blitz3D Beginners Area/Entitycollided
| ||
I have set all of the bullets as collision type 3 some of the enemy ships are type 2 some are type 1 when I do a for-next loop to cycle through the bullets how do I use entitycollided to find out which enemy ship was hit? Or when I cycle through the enemy ships how do I find out which ship was hit? I tried using For tr= 1 To 100 hit_ship= EntityCollided (bullets(tr),1) If hit_ship<>0 HideEntity hit_ship EndIf next but hit_ship is always zero no matter how many times I see the bullet collide |
| ||
The only way I can identify which enemy ship has been hit is by giving each INDIVIDUAL enemy a collision type which slows the game down to 1 FPS CAN ANYONE HELP? |
| ||
Your code will only check bullet 100, as hit_ship is owerwritten before you check if it's <>0. Move the next command down below endif. |
| ||
I tried that and it still doesnt work, check my code again |
| ||
Eh, you did remember making a collisions statement? |
| ||
for i=1 to countcollisions(bullet) hideentity collisionentity(bullet,i) next |
| ||
k=0 For p.blue_ship=Each blue_ship k=k+1 For t = 1 To CountCollisions(redbullets(k)) HideEntity CollisionEntity (redbullets(k),t) Next next I tried this but it doesnt work. Definetly set the collisions because the bullets stop when they hit the enemies |
| ||
Thats not going to work though is it? how many bullets do you have? If there is only one ship then you are only checking 1 bullet, even when there are 100 of them. Read your code again. You set k to 0. No problem. You then loop through all the ships (not bullets) increasing k each time - you then check the amount of collisions that bullet k has. The problem is you're only going to loop through as many bullets as you have ships. If you have 3 ships and 100 bullets you will only check the firt 3 bullets. Have 100 ships and 3 bullets and theres a good chance you will get an error of some sort. you need for b=1 to MaxBullets for i=1 to countcollisions(bullet(b)) hideentity collisionentity(bullet(b),i) next next Forget about looping through the ships. That doesn't matter. |
| ||
thanks it works now |