Hi alls, i am new here and new in Godot. Vew weeks ago, i started to learn Godot with V 2.1...and now i switched to V 3.0. For me its hard to feature out the differences, at least, the is_colliding doesnt exist in V 3.0. in my vertical scroller game i only move the player on x axis via animations (for fixed x coodrinates). the goforward effect i realise by scrolling the backgrounds down.

Can you help me to detect a collision to a nonplayer object?

For better understanding, here is my code:

#Vertical scroller game with moving backgrounds.
#Player only moving on x axis via Animations to fixed x-coordinates
#by pressing keyboard left or right,
#or by pressing buttons (for Android version).
#the "go forward" effect is getting by scrolling the backgrounds and all nonplayer objects.
#The Player has three lines where he can "move" to: left, middle and right
#backgrounds: simple sprites
#player: Sprite -> KinematicBody2D -> CollisionShape2D
#nonplayer (one object, parented on background01): Sprite -> StaticBody2D -> CollisionShape2D
#extends Node2D # main node of gamescene with Backgrounds, Player, Buttons and Playeranimation

var sp_BG1 # Background 01
var sp_BG2 # Background 02
var a_Player # Player Animations = ML (middle to left), LM (left to middle), MR (middle to right) and RM (right to middle)
var line = "middle" # actual line = left, middle and right
var animating = "ready" # is Animation activ? = ready and run
export (float) var bgspeed # vertical scroll speed of Background (and nonPlayer objects)

func _ready(): # define nodes (get_node)
	sp_BG1 = $sp_BG1
	sp_BG2 = $sp_BG2
    a_Player = $a_Player

func _input(event): # PC keys 
 if(Input.is_action_just_pressed("ui_left") && animating == "ready"):
	 if(line == "middle"):
			a_Player.play("a_ML")
	 	line = "left"
 	if(line == "right"):
	 	a_Player.play("a_RM")
	 	line = "middle"
 if(Input.is_action_just_pressed("ui_right") && animating == "ready"):
		if(line == "middle"):
		a_Player.play("a_MR")
		line = "right"
		if(line == "left"):
			a_Player.play("a_LM")
			line = "middle"

func _process(delta):
	if (sp_BG1.position.y <= 1334+667): # Background01 scrolls out of scene
		sp_BG1.translate(Vector2(0,bgspeed))
	else:
		sp_BG1.position.y = -667 # Background01 set top of scene

	if (sp_BG2.position.y <= 1334+667): # Background scrolls out of scene
    	sp_BG2.translate(Vector2(0,bgspeed))
	else:
    	sp_BG2.position.y = -667 # Background set top of scene
func _on_a_Player_animation_started( name ): # Playeranimation is running
	animating = "runs"

func _on_a_Player_animation_finished( name ): # Playeranimation is not running
	animating = "ready"

func _on_b_left_pressed(): # button for Playermoving left via Animation (for Android), similar to PC keys
	if(line == "middle" && animating == "ready"):
		a_Player.play("a_ML")
		line = "left"
	if(line == "right" && animating == "ready"):
		a_Player.play("a_RM")
		line = "middle"

func _on_b_right_pressed(): # button for Playermoving right via Animation (for Android), similar to PC keys
	if(line == "middle" && animating == "ready"):
		a_Player.play("a_MR")
		line = "right"
	if(line == "left" && animating == "ready"):
		a_Player.play("a_LM")
		line = "middle"

...i hope its ok, how i ask my quest and you understand me...if not, dont hasistate to ask me. Oh...and sorry for my bad english!

Nice Day Neo

lol...hard to format right in here xD

I hope this helps you.

you need to use the physics_process function, before called fixed_process. Before to detect a collision with some object, we needed to use the move method of kinematicBody2D, but now, we must use move_and_collide that does the same. As you said there is no is_colliding anymore, but it's not a problem, the move_and_collide function returns the object with which we collide. You could use it like this:

extends KinematicBody2D

func _physics_process (delta):
	var velocity = Vector2 (0, 5) * delta
	var test_colision = move_and_collide (velocity)

	if (col! = null): # if there is no collision return null, but the object
		# what has to happen
	 pass

If this don't help you. I recommend download the demo projects of godot in github of Platformer2D And also that you analyze them well. them are already update to version 3.0! :)

https://github.com/godotengine/godot-demo-projects

Hi rjoshua, thank you for your help.

move_and_collide (velocity) i found this in the past, too...but i cant handle it in my project, because my player doesnt "move" (with physics). my player "moves" in a simulation via animations (only on x axis, left and right), so the main velocity is null on the player. your code above works temporaly, not precise and only while my player "moves", but not exact on collision with object (the object is scrolling down ) i took a look into the platformer sample, but it works with physics. My project is like a space shooter topdown vertical scroller - a player at bottom on screen (only moves on x axis via animation) and two background sprites are scrolling down until out of screen, jump to top of screen and scrolling again down...the "enemies are objects, parented on the background sprite or with there own "scrolling down speed"

my next idea was, to use your code in the enemies, because they can have a velocity...but i got the same result like using this code on the player...

...do i have the total wrong startup for my project? or do i understand totally wrong? background scrolling seems looking so easy xD

Thank you Neo

is the structure of my objects important for collisions? actually: Player: Sprite -> KinematicBody2D -> CollisionShape2D Enemy1: Sprite -> KinematicBody2D -> CollisionShape2D Enemy2: Sprite -> StaticBody2D -> CollisionShape2D

Thank you Neo

Heya again, ok, after searching and trying a lot, here my solution:

enemies getting type Area2D, so i can connect the signal body_entered( Object Body ) and in my script i can in this func check for collision via if body.get_name() == "rb_Player": ...rb_Player is the RigidBody2d of my player...

This works like expected :)

Thank you for help - problem solved :)

Neo `

Oh, wow. I'm glad that your game has finally worked. :)

The idea that the player moves on the x-axis via animation is rare for me, but that is precisely what intrigues me. Do not forget to show us your work.

Regards, Neo!!

5 years later