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 (171 points)

1 Answer

0 votes

i guess you should use this in the physicsproccess

by (26 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 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.

Categories