File size: 1,419 Bytes
8f07272
 
 
 
 
 
 
 
 
 
 
 
0f11a8b
8f07272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
extends Node3D
class_name CharacterModel
@onready var animation_tree : AnimationTree = $AnimationTree
@onready var _playerback : AnimationNodeStateMachinePlayback = animation_tree["parameters/playback"]
@onready var skeleton = $Armature/Skeleton3D
enum States {IDLE, RUN, AIR}

func _ready():
	animation_tree.active = true
	
#    $Armature/Skeleton3D.get_modification_stack().enable_all_modifications(true)
#    $Armature/Skeleton3D.modification_stack.get_modification(0).set_target_node("")
#	$Armature/Skeleton3D.modification_stack.get_modification(0).set_target_node("../../Gun/LeftHandMarker")

func set_team(value):
	var material: Material
	if value == 0:
		material = load("res://tbot_model_green_team.tres")
	elif value == 1:
		material = load("res://tbot_model_red_team.tres")
	print("setting tbot material")
	$Armature/Skeleton3D/Mesh.set_surface_override_material(0, material)

func transition_to(state_id: States): 

	match state_id:
		States.IDLE:
			_playerback.travel("Idle")
		States.RUN:
			_playerback.travel("RunBlend")
		_:
			_playerback.travel("Idle")
			
func set_velocity(velocity: Vector3):
	animation_tree.set("parameters/RunBlend/blend_position", Vector2(velocity.x, velocity.z))
	
		
func set_camera_angle(angle: float):
	$Gun.rotation.x = -angle

func get_gun_info():
	return $Gun/MuzzleMarker.global_position

func toggle_model_mesh(value: bool):
	$Armature/Skeleton3D/Mesh.visible = value