Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | abhaskumarsinha | |
Old Version | Published before Godot 3 was released. |
I’ve wrote a code for camera in GDscript which will help the user to view their models in all paranoma.
Code Link → Godot error - Pastebin.com ← what is the error in the code.
code attached from link
extends Spatial
func _ready():
var x;
var y;
var mouse_sensitivity;
set_process_input(true);
# set the mouse sensitivity of the mouse
var view_sen = 0.2
Input.set_mouse_mode(2);
func _input(ie):
#get present rotation of the scene node
var x = rad2deg(get_node(".").get_rotation().x);
var y = rad2deg(get_node(".").get_rotation().y);
#now get the rotation of the mouse, with mouse x and mouse y
var x = fmod(x - ie.relative_x * 0.2, 360);
var y = fmod(y - ie.relative_y * 0.2, 90);
#now just set the values
get_node(".").set_rotation(Vector3(deg2rad(x), 0, 0));
get_node(".").set_rotation(Vector3(0, deg2rad(y), 0));
print ("" , x);
print ("" , y);
The y axis motion of the mouse is not working.