Josh64

Collision detection (kinda)

Jan 6th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. for _, entity in pairs(Isaac.GetRoomEntities()) do -- go through every entity in the room
  2. if entity.Type ==
  3. and entity.Variant == then -- look for your shield entity
  4. local shield = entity
  5. -- you found your shield entity
  6. for _, entities in pairs(Isaac.GetRoomEntities()) do -- go through every entity in the room again
  7. if entities.Type == EntityType.ENTITY_PROJECTILE then -- look for enemy projectile.
  8. local shot = entities
  9. -- check collision
  10. if (shot.Position - shield.Position):Length() <= shot.Size + shield.Size then
  11. -- remove projetile if it is one the same position than the shield
  12. shot:Remove()
  13. end
  14. end
  15. end
  16. end
  17. end
  18. end
Advertisement
Add Comment
Please, Sign In to add comment