Stuck on edge without VisibilityNotifier2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ondesic

I have a problem I don’t understand. I a using a variation of “Your First Game” tutorial but changing a few things around.
I have a scene with a ship that hits the edge of the screen then bounces off with the following code:

func _process(delta):
	if position.x < 0:
	linear_velocity.x *=-1
	position.x +=1
	

The ship is a:

RigidBody2D
        AnimatedSprite
        CollisionShape2D
        VisibilityNotifier2D

Everything works great and the ship bounces off the edge when it hits the left side of the screen.
HOWEVER, if I delete the VisibilityNotifier2D, the ship hits the edge a slides on the side of the screen. The VisibilityNotifier2D has no signals, no code, nothing. However, if I have it, the bounce code works, without it, gets stuck and slides on the edge.

Can anyone explain this?

Could someone please look at this? I can’t figure it out.

ondesic | 2018-03-22 01:28