The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

Hello,
The idea:
1 You press right mouse button
2 While 1, if you move the mouse, the camera rotates

I tried this, but it gives an aberrant result (just the last part of the script):

  func _input(event):
    # keyboard inputs (xz plane movement)
    if event is InputEventKey:
        # forwards/backwards movement
        if Input.is_action_pressed("move_backwards") and Input.is_action_pressed("move_forwards"):
            pass
        elif Input.is_action_pressed("move_backwards"):
            translation += Vector3(0,0,self.xzSpeed)
        elif Input.is_action_pressed("move_forwards"):
            translation += Vector3(0, 0, -self.xzSpeed)
        # right/left movement
        if Input.is_action_pressed("move_left") and Input.is_action_pressed("move_right"):
            pass
        elif Input.is_action_pressed("move_left"):
            translation += Vector3(-self.xzSpeed, 0, 0)
        elif Input.is_action_pressed("move_right"):
            translation += Vector3(self.xzSpeed, 0, 0)

    elif event is InputEventMouseButton:
        if event.is_pressed():
            # zoom in
            if event.button_index == BUTTON_WHEEL_UP:
                fov -= self.zoomSpeed
            # zoom out
            if event.button_index == BUTTON_WHEEL_DOWN:
                fov += self.zoomSpeed

            # rotate camera
            if Input.is_action_pressed("rotate_camera"):
                var mouseDelta = event.position
                rotation_degrees += Vector3(mouseDelta.y, -mouseDelta.x, 0)
Godot version 3.2.3
in Engine by (255 points)

1 Answer

0 votes

i guess you should use this in the physicsproccess

by (28 points)

This is a part of the solution, but not the solution. Thanks, I think the problem is now in the rotation and the origin.

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.