+3 votes

Hi everybody!

I have an Array with bullets created with the "Bullet Shower demo" method. I was able to determine collisions with enemies (they have an Area2d as a child node), but can't figure out how to determine collision with the walls, floor, etc. (TileMap).
It's important for my game to handle bullets efficiently, because there will be a lot of them.

Tanks in advance and sorry for my English., Is not my first Language.

in Engine by (155 points)

1 Answer

+3 votes

A few things:

  • Are your bullets RigidBody2Ds or KinematicBody2Ds?
  • Do you need separate handling for hitting different types of tiles, like different reactions for hitting walls vs hitting floors?

    • Did you remember to add bodies and collision shapes to your tiles when creating your TileSet?

I made a shooter that used tile maps once, where my bullets were KinematicBody2Ds. In the script attached to the bullet scene, whenever a bullet collided with something I used the bullet's get_collider method to get the object it collided with, then used extends to check its class.

const actor_class = preload("res://scripts/actors/actor.gd")

func _fixed_process(delta):
    var velocity = direction * speed * delta

    if is_colliding():
        var collider = get_collider()
        if collider extends actor_class:


That said, if the bullet hits a wall I believe get_collider will return the tile's StaticBody2D, and not the tile map itself. You can work out what tile got hit though using the collision's location.

by (290 points)

very nice expose.thats my doubt too before

you expose we can load from scripts,so can work better with separations collisions objects on game.


Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.