0 votes

I am following the tutorial to make Dodge the Creeps and found a problem with the screen. Even using:

postition += velocity * delta
position.x = clamp(position.x, 0, screensize.x)
position.y = clamp(position.x, 0, screensize)

The player leaves the screen boundaries (more precisely, to the right and down). It doesn’t move around infinitely, but stops at y 720 (which is actually the size I selected in Project Settings). The problem is that this position does not appear on the screen. I think the problem is not in the code (as i followed the tutorial), but in the project settings, which by the way are:

- Width: 480
- Height: 720
- Resizable: off
- Borderless: off
- Fullscreen: off
- Always on top: off
- Test width: 0
- Test height: 0
- allow dpi: off
- Use vsync: on
- Vsyn via compositor: off
Per pixel transparency:
- allowed: off
- enabled: off
- Orientation: portrait
- Mode: 2d
- Aspect: keep
- Shrink: 1

Godot version 3.3.1
in Engine by (12 points)

1 Answer

+1 vote

This is the line with the error:

position.y = clamp(position.x, 0, screensize)

Replace position.x with position.y

by (1,051 points)
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.
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.