Case
Case

Reputation: 4272

Godot 4.2 - Collision detected on layers that should not interact

Specs

Godot v4.2.stable - Windows 10.0.19045 - Vulkan (Mobile) - dedicated NVIDIA GeForce RTX 3080 (NVIDIA; 31.0.15.3742) - 11th Gen Intel(R) Core(TM) i7-11700KF @ 3.60GHz (16 Threads)

Problem

I have box spawning an item. The item is detecting the box as colliding with it. The item is on layer 5, and masks layer 1 (player). The box is on layer 3 and Masks layer 1, layer 2(enemy), layer 3(projectile). When the item spawn it triggers collision and disappears giving it to the player immediately. The item should only collide with the player and nothing else. Maybe I am missing something.

Item Removal Script

func _on_body_entered(_body):
print("Item Selected", item_sel)
print(item_sel, _body)
if item_sel == "60" && Globals.laser_amt < 20:
    queue_free()
    print("Free")
    Globals.laser_amt = 20
if item_sel == "15" && Globals.grenade_amt < 5:
    queue_free()
    print(Globals.grenade_amt, "Free")
    Globals.grenade_amt += 1;
if item_sel == "20" && Globals.player_health < 100:
    queue_free()
    print(Globals.player_health, "Free")
    Globals.player_health += 20
    if Globals.player_health > 100:
        Globals.player_health == 100

Layer Images

https://imgur.com/a/C2bLPLN

Upvotes: 1

Views: 340

Answers (1)

Case
Case

Reputation: 4272

In a case like this, if you make an object and set it up outside of the level you are making. You must also check in the level itself to see what the collisions are set to. The level might be overwriting the collisions of the item self. So select you item in the level and verify the collision layers that way.

Upvotes: 1

Related Questions