0 votes

when i move around i cant look around i cant do both aat once what should i do?

in Engine by (35 points)

1 Answer

+1 vote

If you connect your camera to the mouse you could have a separate moving sprite and the ability to move the camera around. You would need some code to check if the sprite is still on the screen if you want to limit the camera in that way though.

by (3,053 points)

can you show me exampe of coding iam still new to this

This forum is really for answering specific questions I cannot write all the code for you but I can give some pointers to try to help.

If you have something like this attached to the camera in a scene as a script;

var DistanceToCharacter = 0

func _input(event: InputEvent) -> void:
    if event is InputEventMouseMotion:
        var move = event.position - get_viewport().size * 0.5
        if move.length() < DistanceToCharacter:
            self.position = vector2(0, 0)
            self.position = move.normalized() * (move.length() * DistanceToCharacter) * 0.5

this would allow you to set the camera to follow the mouse. If you then tie the variable DistanceToCharacter to some code which checks how far it is from your sprite it will allow you to control the camera the way you want. Or at least it should, I havent tested this its just how I would program it.

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.