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.


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

in Engine by (15 points)

1 Answer

0 votes
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.

by (1,328 points)
selected by
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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.