This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

why it collide yet sometime didn't update as collide? https://youtu.be/5wAEvCWrTyM
something wrong with code? or something else?

func _physics_process(delta: float) -> void:
    if path.size() > 1:
        var distance = get_position().distance_to(path[0])
        if distance > 2 :
            set_position(get_position().linear_interpolate(path[0],(move_speed*delta)/distance))
        else:
            path.remove(0)
    else:
        move_speed =0

    var collision = move_and_collide(Vector2.ZERO)
    if collision:
        var colider = collision.collider
        if colider.is_in_group("bullet") :
            print("collider")
            queue_free()
in Engine by (429 points)

var colider
if colider

You sure those are supposed to only have one "L" each?

yeah, i make var bit different than collider

Which part is not working? Detecting the collision itself or detecting that the collider is in the group "bullet"? And why are you using move_and_collide with a zero-vector?

they colliding(colliding always working), but sometime it detecting that the collider is in the group "bullet", sometime not.

because enemy move use navigation2d? i dont know what to put in that.

because enemy move use navigation2d? i dont know what to put in that.

I never used Navigation2D, so I might be wrong. But instead of directly setting the position of your enemy with set_position you could also use move_and_collide, isn't it? With move_and_collide you check if something is blocking the way (described by velocity). If I only want to check for collisions where I already am, I'd use an Area2D.

they colliding, but sometime it detecting that the collider is in the group "bullet", sometime not.

Assuming that move_and_collide still registers every collision at the current position even when the velocity-vector is equal to zero (which I haven't tested, but you said it does) and granted that you never have issues accessing the collider (which should lead to an error if it happens), the only potential problem left would be that the collider isn't in the correct group. If you sure it is, I have absolutely no idea. :(

can area2D detect kinematic2D? or should i put area2D for both bullet and mob? or remove kinematic2D and use area2d? can area2D make bounce effect??
i think to change to area2D.

and when it didn't detect isingroup, error didn't show up.

file if you want to check https://drive.google.com/open?id=1Upm1JgYCF-FXW_0BGBkr1vz6hDzDzlYa

can area2D detect kinematic2D?

Yes.

or should i put area2D for both bullet and mob?

That would work as well. If it makes sense for your project, is a different question.

can area2D make bounce effect??

No. Or at least it's a lot easier to do with a KinematicBody2D or RigidBody2D.

file if you want to check

I'm confused. In that project you don't check for the group of the collider, but for the name. I already told you, that's not a good idea over here.

this consider check name? not group?
enemy

var collision = move_and_collide(Vector2())
    if collision:
        var colider = collision.collider
        if colider.is_in_group("bullet") :
            print("collider")

            queue_free()

        if colider.is_in_group("tower_need_to_deffend") :
            print("collider with player tower")




            global_data.player_life -=1
            queue_free()

enter image description here

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.