+1 vote

A small question,
How can I prevent the paddle's KinematicBody2D sprites from breaking out of the screen beyond the screen?
Note: How do you receive the size of the stage when you create a game to scroll?
(in the future.)

asked Nov 15, 2017 in Engine by keito940 (48 points)

1 Answer

+1 vote
Best answer

You can find the size of the viewport with:


I don't know what "paddles" you mean, but you can clamp movement to the viewport in your positioning code. The sample Dodge Game has a good example of how to use it. Keep in mind that Dodge is written for V3.0, but "clamp" works the same for the stable version.

answered Nov 15, 2017 by Michael Paul (304 points)
selected Nov 17, 2017 by keito940

So I'm trying the Dodge Game example but clamping isn't working. I tried the code myself and even copy-pasted from the tutorial. It says "Unexpected Token: Identifier: Position"

I'm not sure what's happening. I've read the tutorial up and down.
The tutorial in question:

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.