blob: e5911005a9f318437e0279a4ced87f69abfa633a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# Hurry Curry! - a game about cooking
# Copyright (C) 2025 Hurry Curry! contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, version 3 of the License only.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
class_name CatEars
extends Node3D
const EAR_ROTATION := deg_to_rad(20.)
var ear_target := 0.
@onready var character: Character = get_parent().get_parent().get_parent().get_parent()
func set_inner_mat(mat: BaseMaterial3D):
$Left.set_surface_override_material(1, mat)
$Right.set_surface_override_material(1, mat)
func set_outer_mat(mat: BaseMaterial3D):
$Left.set_surface_override_material(0, mat)
$Right.set_surface_override_material(0, mat)
func _ready() -> void:
set_inner_mat(character.main.get_active_material(0))
set_outer_mat(character.hair_mesh.get_active_material(0))
var t := 0.
func _process(delta: float) -> void:
if visible:
$Right.rotation.z = G.interpolate_angle($Right.rotation.z, ear_target + EAR_ROTATION, delta * 10.)
$Left.rotation.z = G.interpolate_angle($Left.rotation.z, PI + ear_target + EAR_ROTATION, delta * 10.)
if character.walking:
t += delta
ear_target = sin(t * character.WALK_ANIM_SPEED) * 0.075 if character.walking else 0.
else:
t = 0
ear_target = 0.
|