0 votes

I am scaling a node containing a KinematicBody2D, a Sprite, and a CollisionShape2D (rectangle) and trying to detect when this collides with another KinematicBody2D or StaticBody2D.

I have another KinematicBody2D ball bouncing around the scene, and it can interact with these nodes while they are scaling. It bounces correctly off of them both while the tween is going on, and when it stops. My problem is that I want to stop the tween when these nodes come in contact with each other, and I'm struggling to detect that collision.

I drop several of these nodes on top of each other, or have them intersecting and print(is_colliding()) is always false.

Screenshot

In this screenshot, the vertical and horizontal lines are these nodes. The ball is successfully trapped, and bouncing around in that little box in the lower portion of the screen.

If I press the button, a new node will be placed at the top of the screen, just above the arrow and start scaling downward. I'd like to detect, and stop this scaling it when it hits the top horizontal line, but I'm having difficulty detecting that collision.

All of these nodes are layer 1 with a mask of 1, while the ball is on layer 2 with a mask of 1 and 2

asked Aug 16, 2017 in Engine by TomLarrow (15 points)

1 Answer

+1 vote
Best answer

1) Never scale physics bodies (including KinematicBody) or collisionshapes. You can change the shape (width/height) of a collisionshape, but its scale should always be 1 1.

2) KinematicBody.is_colliding() will only return true if it's colliding while in motion using move() or similar. More than likely though, you don't actually need collision in your situation, only hit detection.

answered Aug 16, 2017 by YeOldeDM (1,310 points)
selected Aug 22, 2017 by TomLarrow
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 How to use this Q&A? before posting your first questions.