generated from krampus/template-godot4
	Orbital cam has a configurable offset
This commit is contained in:
		
							parent
							
								
									e8e4bca034
								
							
						
					
					
						commit
						6a19ab8de2
					
				| @ -1,4 +1,4 @@ | |||||||
| [gd_scene load_steps=30 format=3 uid="uid://bm2o3mex10v11"] | [gd_scene load_steps=34 format=3 uid="uid://bm2o3mex10v11"] | ||||||
| 
 | 
 | ||||||
| [ext_resource type="Terrain3DStorage" uid="uid://bu1gewgsgc5hm" path="res://levels/debug_level/terrain_3d_storage.res" id="1_nlsu2"] | [ext_resource type="Terrain3DStorage" uid="uid://bu1gewgsgc5hm" path="res://levels/debug_level/terrain_3d_storage.res" id="1_nlsu2"] | ||||||
| [ext_resource type="Texture2D" path="res://assets/textures/grass_fairway/grass_fairway_albedo.dds" id="2_e4m27"] | [ext_resource type="Texture2D" path="res://assets/textures/grass_fairway/grass_fairway_albedo.dds" id="2_e4m27"] | ||||||
| @ -13,6 +13,7 @@ | |||||||
| [ext_resource type="PackedScene" uid="uid://cjubxs7peir5k" path="res://src/scenery/city/kana_signboard.tscn" id="11_evxup"] | [ext_resource type="PackedScene" uid="uid://cjubxs7peir5k" path="res://src/scenery/city/kana_signboard.tscn" id="11_evxup"] | ||||||
| [ext_resource type="PackedScene" uid="uid://di7aql54lksn7" path="res://src/scenery/trees/palm_tree/palm_tree.tscn" id="12_sswxf"] | [ext_resource type="PackedScene" uid="uid://di7aql54lksn7" path="res://src/scenery/trees/palm_tree/palm_tree.tscn" id="12_sswxf"] | ||||||
| [ext_resource type="PackedScene" uid="uid://c7l58wuuahn7w" path="res://src/props/flag.tscn" id="13_6jtao"] | [ext_resource type="PackedScene" uid="uid://c7l58wuuahn7w" path="res://src/props/flag.tscn" id="13_6jtao"] | ||||||
|  | [ext_resource type="Texture2D" uid="uid://dj60e8ri2fco" path="res://assets/models/scenery/city/concrete_building_1/concrete_building_1.png" id="14_y7s2h"] | ||||||
| 
 | 
 | ||||||
| [sub_resource type="FastNoiseLite" id="FastNoiseLite_rpgb7"] | [sub_resource type="FastNoiseLite" id="FastNoiseLite_rpgb7"] | ||||||
| noise_type = 0 | noise_type = 0 | ||||||
| @ -125,6 +126,17 @@ size = Vector2(4096, 4096) | |||||||
| subdivide_width = 256 | subdivide_width = 256 | ||||||
| subdivide_depth = 256 | subdivide_depth = 256 | ||||||
| 
 | 
 | ||||||
|  | [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_5p7vs"] | ||||||
|  | albedo_texture = ExtResource("14_y7s2h") | ||||||
|  | uv1_scale = Vector3(300, 800, 1) | ||||||
|  | 
 | ||||||
|  | [sub_resource type="BoxMesh" id="BoxMesh_20p1k"] | ||||||
|  | material = SubResource("StandardMaterial3D_5p7vs") | ||||||
|  | size = Vector3(300, 1, 800) | ||||||
|  | 
 | ||||||
|  | [sub_resource type="BoxShape3D" id="BoxShape3D_g31tw"] | ||||||
|  | size = Vector3(300, 1, 800) | ||||||
|  | 
 | ||||||
| [node name="TestLevel" type="Node3D"] | [node name="TestLevel" type="Node3D"] | ||||||
| 
 | 
 | ||||||
| [node name="Terrain3D" type="Terrain3D" parent="."] | [node name="Terrain3D" type="Terrain3D" parent="."] | ||||||
| @ -166,3 +178,12 @@ transform = Transform3D(-0.69799, 0, -0.716107, 0, 1, 0, 0.716107, 0, -0.69799, | |||||||
| 
 | 
 | ||||||
| [node name="Flag" parent="." instance=ExtResource("13_6jtao")] | [node name="Flag" parent="." instance=ExtResource("13_6jtao")] | ||||||
| transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 540, 4, 452) | transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 540, 4, 452) | ||||||
|  | 
 | ||||||
|  | [node name="DebugTable" type="MeshInstance3D" parent="."] | ||||||
|  | transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 160.1, 0, 885.605) | ||||||
|  | mesh = SubResource("BoxMesh_20p1k") | ||||||
|  | 
 | ||||||
|  | [node name="StaticBody3D" type="StaticBody3D" parent="DebugTable"] | ||||||
|  | 
 | ||||||
|  | [node name="CollisionShape3D" type="CollisionShape3D" parent="DebugTable/StaticBody3D"] | ||||||
|  | shape = SubResource("BoxShape3D_g31tw") | ||||||
|  | |||||||
| @ -3,6 +3,7 @@ class_name OrbitalCamera extends Node3D | |||||||
| const POSITION_ACCELERATION := 4.0 | const POSITION_ACCELERATION := 4.0 | ||||||
| 
 | 
 | ||||||
| @export var target: Node3D | @export var target: Node3D | ||||||
|  | @export var offset := Vector3(0, 1, 0) | ||||||
| 
 | 
 | ||||||
| @export var angular_speed := 0.007 | @export var angular_speed := 0.007 | ||||||
| 
 | 
 | ||||||
| @ -13,7 +14,9 @@ static var scene := preload("res://src/player/orbital_camera/orbital_camera.tscn | |||||||
| 
 | 
 | ||||||
| func _physics_process(delta: float) -> void: | func _physics_process(delta: float) -> void: | ||||||
| 	# Update position | 	# Update position | ||||||
| 	global_position = global_position.lerp(target.global_position, delta * POSITION_ACCELERATION) | 	global_position = global_position.lerp( | ||||||
|  | 		target.global_position + offset, delta * POSITION_ACCELERATION | ||||||
|  | 	) | ||||||
| 
 | 
 | ||||||
| 	# Update rotation | 	# Update rotation | ||||||
| 	camera.look_at(target.global_position) | 	camera.look_at(target.global_position) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user