jostick camera
This commit is contained in:
		
							parent
							
								
									16d31becb5
								
							
						
					
					
						commit
						b4e0603e33
					
				
					 3 changed files with 43 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -23,7 +23,7 @@
 | 
			
		|||
[ext_resource type="PackedScene" uid="uid://c4s6y758n77lw" path="res://villager_shared.tscn" id="24_ddfvk"]
 | 
			
		||||
[ext_resource type="PackedScene" uid="uid://b3aus2kigf8xt" path="res://Models/beach_decor/cooler.tscn" id="24_sl7ne"]
 | 
			
		||||
[ext_resource type="PackedScene" uid="uid://cft26nug7kyqb" path="res://ambient_light_1.tscn" id="25_novxt"]
 | 
			
		||||
[ext_resource type="PackedScene" path="res://color_cube.tscn" id="25_rm0cr"]
 | 
			
		||||
[ext_resource type="PackedScene" uid="uid://ukful430mmkn" path="res://color_cube.tscn" id="25_rm0cr"]
 | 
			
		||||
[ext_resource type="PackedScene" uid="uid://bw3k2c75qavce" path="res://Models/beach_decor/bucket.tscn" id="27_f3p1i"]
 | 
			
		||||
[ext_resource type="PackedScene" uid="uid://g4gmc0pwlak1" path="res://Models/buildings/fence.tscn" id="28_prydb"]
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,6 +27,14 @@ func _process(_delta):
 | 
			
		|||
	if obj:
 | 
			
		||||
		obj.global_transform.origin = $grape_man.get_pickup_bone_location()
 | 
			
		||||
		
 | 
			
		||||
	var event = Input.get_vector("camera_left", "camera_right", "camera_up", "camera_down") * 4
 | 
			
		||||
 | 
			
		||||
	rotate_y(deg_to_rad(-event.x * horiz_sens))
 | 
			
		||||
	$CameraMount.rotate_x(deg_to_rad(-event.y * vert_sens))
 | 
			
		||||
	var roty = deg_to_rad(event.x * horiz_sens)
 | 
			
		||||
	$grape_man.rotate_y(roty)
 | 
			
		||||
	$CameraMount.global_rotation.x = clampf($CameraMount.global_rotation.x, deg_to_rad(-60), deg_to_rad(-11))
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
func _input(event):
 | 
			
		||||
	# Handle the rotation of the camera using mouse movement.
 | 
			
		||||
| 
						 | 
				
			
			@ -37,6 +45,16 @@ func _input(event):
 | 
			
		|||
		$grape_man.rotate_y(roty)
 | 
			
		||||
		$CameraMount.global_rotation.x = clampf($CameraMount.global_rotation.x, deg_to_rad(-60), deg_to_rad(-11))
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	if event is InputEventMouseMotion:
 | 
			
		||||
		rotate_y(deg_to_rad(-event.relative.x * horiz_sens))
 | 
			
		||||
		$CameraMount.rotate_x(deg_to_rad(-event.relative.y * vert_sens))
 | 
			
		||||
		var roty = deg_to_rad(event.relative.x * horiz_sens)
 | 
			
		||||
		$grape_man.rotate_y(roty)
 | 
			
		||||
		$CameraMount.global_rotation.x = clampf($CameraMount.global_rotation.x, deg_to_rad(-60), deg_to_rad(-11))
 | 
			
		||||
		
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	if Input.is_action_just_pressed("ui_accept"):
 | 
			
		||||
		var obj = holding.get_ref()
 | 
			
		||||
		if obj:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -56,7 +56,7 @@ ui_left={
 | 
			
		|||
"deadzone": 0.5,
 | 
			
		||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194319,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
 | 
			
		||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
 | 
			
		||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null)
 | 
			
		||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
 | 
			
		||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null)
 | 
			
		||||
]
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -64,7 +64,7 @@ ui_right={
 | 
			
		|||
"deadzone": 0.5,
 | 
			
		||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194321,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
 | 
			
		||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
 | 
			
		||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null)
 | 
			
		||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
 | 
			
		||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null)
 | 
			
		||||
]
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -72,7 +72,7 @@ ui_up={
 | 
			
		|||
"deadzone": 0.5,
 | 
			
		||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194320,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
 | 
			
		||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
 | 
			
		||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
 | 
			
		||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
 | 
			
		||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null)
 | 
			
		||||
]
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -80,7 +80,7 @@ ui_down={
 | 
			
		|||
"deadzone": 0.5,
 | 
			
		||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194322,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
 | 
			
		||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
 | 
			
		||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
 | 
			
		||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
 | 
			
		||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null)
 | 
			
		||||
]
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -96,3 +96,23 @@ Pause={
 | 
			
		|||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":false,"script":null)
 | 
			
		||||
]
 | 
			
		||||
}
 | 
			
		||||
camera_up={
 | 
			
		||||
"deadzone": 0.0,
 | 
			
		||||
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)
 | 
			
		||||
]
 | 
			
		||||
}
 | 
			
		||||
camera_down={
 | 
			
		||||
"deadzone": 0.0,
 | 
			
		||||
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
 | 
			
		||||
]
 | 
			
		||||
}
 | 
			
		||||
camera_right={
 | 
			
		||||
"deadzone": 0.0,
 | 
			
		||||
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null)
 | 
			
		||||
]
 | 
			
		||||
}
 | 
			
		||||
camera_left={
 | 
			
		||||
"deadzone": 0.0,
 | 
			
		||||
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":-1.0,"script":null)
 | 
			
		||||
]
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue