Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | tmk3 |
Hi,
I’m new in Godot and I try to do some FPS controller with yt tutorial. How can I translate gdscript code:
func _input(event):
if event is InputEventMouseMotion:
head.rotate_y(deg2rad(event.relative.x * 0.3))
head is just a spatial node: onready var head = $Head
I have in my cpp file:
void godot::Player::_input(InputEvent* event)
{
InputEventMouseMotion* m = Object::cast_to<InputEventMouseMotion>(event);
Node* head = Object::cast_to<Node>(get_node("Head"));
if (m)
{
//auto head_rotate_y = Object::cast_to<Spatial>(head)->rotate_y(Math::deg2rad());
}
}
but I don’t know how to get access to “relative”, can you help me, please?