0 votes

So I have this code here for a game with only left and right movement. I built in a clamp function so I don't have to bother with collision and walls (most of it is point, click and L/R movement).

My clamp function so far is working as needed. I am using a function to catch screen size at ready and have a "margin" variable to export at the top of this movement script's parent object:

    direction.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")

var movement = direction * speed * delta

var x_limit_l = (0 - ((screen_size.x/2)-marg))
var x_limit_r = ((screen_size.x/2)-marg)
position.x = clamp(position.x, x_limit_l, x_limit_r)

My levels will have a very controlled size and I am working in letterbox format. However I am wondering if this coding will be a problem once I do longer rooms. Is there a way to adjust this for level size vs screen size or am I better off just dragging collision boxes into every single room? (This would be a pain as I am using a procedural generation engine of sorts).

Godot version v3.4.3.stable.official [242c05d12]
in Engine by (548 points)

Please log in or register to answer this 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 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 [email protected] with your username.