+1 vote

I'm making battle city like game without grid movement and having trouble with bullet collision.

1: Outer angle tile collision, bullet cant detect collided tile the bullet disappear and tile not remove.

2: Remove both bullet when bullet collision, some time both removed and some time only one removed

enter image description here

Here is my bullet code:

extends KinematicBody2D

var speed = 500
var velocity = Vector2()

func start(pos, dir):

rotation = dir
position = pos
velocity = Vector2(speed, 0).rotated(dir-PI/2)

func physicsprocess(delta):

var collision = move_and_collide((velocity * delta).round())
if collision:
    velocity = velocity.bounce(collision.normal)
    if collision.collider is TileMap:
        var tile = collision.collider.world_to_map(collision.position - velocity.normalized())
        if collision.collider.get_cellv(tile) == 0:
            collision.collider.set_cell(tile.x, tile.y, -1)
    elif collision.collider.name == "Enemy" or collision.collider.name == "Player":

func onVisibilityNotifier2Dscreenexited():

Edit: Look like i use moveandcollide() wrong??
Edit 2: 2nd problem solved by add hit() method to all object

in Engine by (13 points)
edited by

Please log in or register to answer this question.

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 [email protected] with your username.