0 votes

I am working on a 3D TPS shooting games where my player needs a camera to follow. This is my code note.

func _unhandled_input(event): # This function for mouse direction 
    if event is InputEventMouseMotion:

func _physics_process(delta):

However this code only works in horizontal way means i can see and move only in left right direction. Now i want to know how see Up and down(like seeing a tall building just seeing not moving our charcter)in camera through mouse motion.

in Engine by (37 points)

1 Answer

+1 vote

Not sure which direction your axis's are pointing so you'll have to adjust rotate_xyz() accordingly a direct answer to your question would be

func _unhandled_input(event): # This function for mouse direction 
    if event is InputEventMouseMotion:

func _physics_process(delta):

That should work however may create another problem, so recommend locking mouse to the window

func _ready():

Set the camera to be the child of a spatial and manipulate the transforms of that instead

by (6,264 points)

Thanks! for your suggestion but i have already used this technique except that capturing code. But it still did not worked.
But again thanks for suggestion.

i found the solution here is my new code for vertical view

func _unhandled_input(event): # This function is  for mouse direction 
if event is InputEventMouseMotion:
    cam_rotate.rotate_x(-lerp(0,spin,event.relative.y/100)) # This is for the vertical mouse motion
    rotate_y(-lerp(0,spin,event.relative.x/20)) # This is for the horizontal mouse motion 
    #cam_rotate-> onready var cam_rotate = get_node("camera")

If anyone have more suggestion i will be thankful to him.

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.