Rigidbody2d collisions not detected

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By NotADuck
:warning: Old Version Published before Godot 3 was released.

Hello, I’m having some trouble with the Rigidbody2d class and its get_colliding_bodies function.
I’m making an endless runner close to Google Chrome’s dino just to test out the engine but I’m having some trouble detecting the collisions between the player and the obstacles.
This is my code so far:

func _input(event):
	if event.is_action_pressed("game_jump"):
		speed.y = JUMP_FORCE * (-1)

func _fixed_process(delta):
	speed.x = 0
	speed.y += GRAVITY * delta
	velocity = Vector2(speed.x*delta,speed.y*delta)
	get_node("player").set_linear_velocity(Vector2(speed.x,speed.y))
	
        if inst != null :
		inst.move(Vector2(-envSpeed,0)*delta)

	print(get_node("player").get_colliding_bodies().size())
	
	if spawnTimer >= 3:
		inst = load("res://pawns/obstacles/funky_cactus.xml").instance()
		inst.set_global_pos(Vector2(660,300))
		inst.add_to_group("obstacles")
		add_child(inst)
		spawnTimer = 0

	spawnTimer += delta

Basically every time the player spawns it hits the ground and it stays there and get_colliding_bodies().size()is equals to 1 but every time an obstacle comes to the player the size of the array of colliding bodies is always 1.

:bust_in_silhouette: Reply From: kidscancode

Have you set “Contact Monitor” to On and “Contacts Reported” to a value greater than 0?

I have already enabled the “Contact Monitor” and I have set the “Contacts Reported” to 5 (just to be sure)

NotADuck | 2017-11-13 14:13

:bust_in_silhouette: Reply From: GhostBall338

some times, when i try to put in a picture, or a figure in rigidbody2D, i just have to expand it! idk if thats What you are looking for, but thats all i got bro! im new jsyk.