fix camera pivot on daynight controllwer
This commit is contained in:
@@ -235,22 +235,6 @@ func _process(delta: float) -> void:
|
|||||||
environment_config.material_fog.set_shader_parameter("night_intensity", night_val)
|
environment_config.material_fog.set_shader_parameter("night_intensity", night_val)
|
||||||
environment_config.material_fog.set_shader_parameter("sun_color", final_tint)
|
environment_config.material_fog.set_shader_parameter("sun_color", final_tint)
|
||||||
|
|
||||||
func _set_camera(curr_camera: Camera3D):
|
|
||||||
camera = curr_camera
|
|
||||||
|
|
||||||
func _follow_camera() -> void:
|
|
||||||
if not camera or not is_instance_valid(camera):
|
|
||||||
return
|
|
||||||
var cam_pos: Vector3 = camera.global_position
|
|
||||||
if particles_rain:
|
|
||||||
particles_rain.global_position = Vector3(cam_pos.x, particles_rain.position.y, cam_pos.z)
|
|
||||||
if particles_snow:
|
|
||||||
particles_snow.global_position = Vector3(cam_pos.x, particles_snow.position.y, cam_pos.z)
|
|
||||||
if particles_wind:
|
|
||||||
particles_wind.global_position = Vector3(cam_pos.x, cam_pos.y, cam_pos.z)
|
|
||||||
if particles_fireflies:
|
|
||||||
particles_fireflies.global_position = Vector3(cam_pos.x, particles_fireflies.position.y, cam_pos.z)
|
|
||||||
|
|
||||||
func create_sound_players():
|
func create_sound_players():
|
||||||
rain_audio_player = AudioStreamPlayer.new()
|
rain_audio_player = AudioStreamPlayer.new()
|
||||||
rain_audio_player.name = "RainAudioPlayer"
|
rain_audio_player.name = "RainAudioPlayer"
|
||||||
@@ -263,6 +247,31 @@ func create_sound_players():
|
|||||||
thunder_audio_player.volume_db = environment_config.thunder_audio_volume_db
|
thunder_audio_player.volume_db = environment_config.thunder_audio_volume_db
|
||||||
add_child(thunder_audio_player)
|
add_child(thunder_audio_player)
|
||||||
|
|
||||||
|
#region camera
|
||||||
|
func _set_camera(curr_camera: Camera3D):
|
||||||
|
camera = curr_camera
|
||||||
|
|
||||||
|
func _get_weather_anchor_position() -> Variant:
|
||||||
|
if camera_pivot and is_instance_valid(camera_pivot):
|
||||||
|
return camera_pivot.global_position
|
||||||
|
if camera and is_instance_valid(camera):
|
||||||
|
return camera.global_position
|
||||||
|
return null
|
||||||
|
|
||||||
|
func _follow_camera() -> void:
|
||||||
|
var cam_pos = _get_weather_anchor_position()
|
||||||
|
if cam_pos == null:
|
||||||
|
return
|
||||||
|
if particles_rain:
|
||||||
|
particles_rain.global_position = Vector3(cam_pos.x, particles_rain.position.y, cam_pos.z)
|
||||||
|
if particles_snow:
|
||||||
|
particles_snow.global_position = Vector3(cam_pos.x, particles_snow.position.y, cam_pos.z)
|
||||||
|
if particles_wind:
|
||||||
|
particles_wind.global_position = Vector3(cam_pos.x, cam_pos.y, cam_pos.z)
|
||||||
|
if particles_fireflies:
|
||||||
|
particles_fireflies.global_position = Vector3(cam_pos.x, particles_fireflies.position.y, cam_pos.z)
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Fireflies
|
#region Fireflies
|
||||||
|
|
||||||
func toggle_fireflies(value: bool):
|
func toggle_fireflies(value: bool):
|
||||||
@@ -505,8 +514,9 @@ func spawn_single_godray() -> void:
|
|||||||
var random_z: float = randf_range(-environment_config.godray_spawn_radius, environment_config.godray_spawn_radius)
|
var random_z: float = randf_range(-environment_config.godray_spawn_radius, environment_config.godray_spawn_radius)
|
||||||
|
|
||||||
var center := Vector3.ZERO
|
var center := Vector3.ZERO
|
||||||
if camera and is_instance_valid(camera):
|
var anchor_pos = _get_weather_anchor_position()
|
||||||
center = camera.global_position
|
if anchor_pos != null:
|
||||||
|
center = anchor_pos
|
||||||
ray.global_position = Vector3(center.x + random_x, environment_config.godray_spawn_height, center.z + random_z)
|
ray.global_position = Vector3(center.x + random_x, environment_config.godray_spawn_height, center.z + random_z)
|
||||||
if ray.has_method("set_visual_rotation_degrees"):
|
if ray.has_method("set_visual_rotation_degrees"):
|
||||||
ray.call("set_visual_rotation_degrees", environment_config.godray_rotation_degrees)
|
ray.call("set_visual_rotation_degrees", environment_config.godray_rotation_degrees)
|
||||||
|
|||||||
Reference in New Issue
Block a user