update animation + adding multiple creature + escape to stop instance when are playing

This commit is contained in:
AleaJactaEst 2021-09-08 23:19:32 +02:00
parent e8f6a8ad49
commit 75e5b05b24
10 changed files with 278 additions and 37 deletions

View file

@ -1,15 +1,4 @@
1/ To check error on
Impossible de charger le script de lextension depuis le chemin : «res://addons/kh_window/kh_window_plugin.gd». Cela peut être dû à une erreur de programmation dans ce script.
2/
17/06/2021 | 21:49:01 Zatalyz: pour les nouveautés : il faudrait que le texte ne demande pas de scroll horizontal, qu'il s'adapte à la largeur de cette fenêtre. 80 caractères si tu cherche la meilleure taille pour ce morceau :)
VERSION GODOT : 3.3.3
https://downloads.tuxfamily.org/godotengine/3.3.3/Godot_v3.3.3-stable_x11.64.zip
dépend de la taille du texte, si trop grand ..., mais bonne remarque je note
17/06/2021 | 21:52:17 Zatalyz: ha, un détail : quand on choisit "tête", c'est pas mal de zoomer sur la tête
17/06/2021 | 21:52:47 Zatalyz: Ha oui, le nom commence par M, donc ça l'a fait apparaitre... je dirais : pas de raccourci sur cet écran :D
17/06/2021 | 21:53:07 Zatalyz: (zoomer automatiquement... j'ai trouvé le zoom sinon)
3/ je note ajouter un icon pour juke box

View file

@ -24,6 +24,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://ressources/scripts/creatures/creature.gd"
}, {
"base": "KinematicBody",
"class": "CreatureRoot",
"language": "GDScript",
"path": "res://scenes/player/creature_root.gd"
}, {
"base": "Node",
"class": "Creature_old",
"language": "GDScript",
@ -98,6 +103,7 @@ _global_script_class_icons={
"Cloth": "",
"Creature": "",
"CreatureOld": "",
"CreatureRoot": "",
"Creature_old": "",
"Data": "",
"Equipment": "",
@ -268,7 +274,7 @@ interact={
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null)
]
}
menu_pause={
menu={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":80,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"unicode":0,"echo":false,"script":null)

79
scenes/game/alpha.gd Normal file
View file

@ -0,0 +1,79 @@
extends Spatial
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# var list_creature = []
func generate_map(pos : Vector3):
Config.msg_info("Generate Map")
# Clear old map
for n in $map.get_children():
$map.remove_child(n)
n.queue_free()
# Push new map
for y in range(-20, 21):
for x in range(-20, 21):
var z = (x + y) * (x - y)
if z < 0:
z = -z
var position:Vector3 = 10.0 * Vector3( x, 0.0, y )
var name = "res://scenes/game/area_0_0.tscn"
if int(z/3) % 3 == 0:
if z % 2 == 0:
name = "res://scenes/game/area_0_0.tscn"
else:
name = "res://scenes/game/area_0_1.tscn"
elif int(z/3) % 3 == 1:
if z % 2 == 0:
name = "res://scenes/game/area_1_0.tscn"
else:
name = "res://scenes/game/area_1_1.tscn"
else:
if z % 2 == 0:
name = "res://scenes/game/area_1_2.tscn"
else:
name = "res://scenes/game/area_2_2.tscn"
Config.msg_info("Map:" + str(x) + ":" + str(y) + " -> " + name + " : "+ str(z) + " / " + str(int(z/3)%3))
var map:Spatial = load( name ).instance()
map.set_translation(position)
$map.add_child( map )
func add_creature(name:String, model:String, position:Vector3, orientation:Vector3):
var creature:Spatial = load( model ).instance()
creature.set_name(name)
creature.set_rotation(orientation)
creature.set_translation(position)
# list_creature.push_back(creature)
$creatures.add_child(creature)
func move_creature(name, model, posx, posy, posz):
var position:Vector3 = Vector3( posx, posy, posz )
if $creatures.has_node(name):
var creature:Spatial = $creatures.get_node(name)
var pos : Vector3 = $creature.get_global_transform().origin
# $creatures.get_node(name).get_
# Called when the node enters the scene tree for the first time.
func _ready():
var current: Vector3 = Vector3( 0.0, 0.0, 0.0 )
generate_map(current)
self.add_creature("RA_1", "res://scenes/player/creature_raference.tscn", Vector3( 1.0, 1.0, 1.0 ), Vector3( 0.0, 0.0, 0.0 ))
self.add_creature("RA_2", "res://scenes/player/creature_raference.tscn", Vector3( 2.0, 0.01, 5.0 ), Vector3( 0.0, 1.0, 0.0 ))
self.add_creature("RA_3", "res://scenes/player/creature_raference.tscn", Vector3( 1.0, 0.01, 5.0 ), Vector3( 0.0, -3.141592, 0.0 ))
self.add_creature("Arche_1", "res://scenes/player/creature_arche.tscn", Vector3( -2.0, 0.01, 2.0 ), Vector3( 0.0, -3.141592, 0.0 ))
self.add_creature("Isidor_1", "res://scenes/player/creature_isidor.tscn", Vector3( -2.0, 0.01, 5.0 ), Vector3( 0.0, -3.141592, 0.0 ))
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
Config.msg_info("update Map")
pass

View file

@ -10,3 +10,5 @@ script = ExtResource( 5 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.01, 0 )
[node name="map" type="Spatial" parent="."]
[node name="creatures" type="Spatial" parent="."]

42
scenes/game/model.tscn Normal file
View file

@ -0,0 +1,42 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://scenes/game/area_1_0.tscn" type="PackedScene" id=1]
[ext_resource path="res://scenes/game/area_0_0.tscn" type="PackedScene" id=2]
[ext_resource path="res://scenes/game/area_1_1.tscn" type="PackedScene" id=3]
[ext_resource path="res://scenes/game/area_0_1.tscn" type="PackedScene" id=4]
[ext_resource path="res://scenes/game/area_1_2.tscn" type="PackedScene" id=6]
[ext_resource path="res://scenes/game/area_2_2.tscn" type="PackedScene" id=7]
[ext_resource path="res://scenes/player/playerB.tscn" type="PackedScene" id=8]
[node name="spatial" type="Spatial"]
[node name="player" parent="." instance=ExtResource( 8 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.01, 0 )
[node name="area_0_0" parent="." instance=ExtResource( 2 )]
[node name="area_0_1" parent="." instance=ExtResource( 4 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 10, 0, 0 )
[node name="area_1_0" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 10 )
[node name="area_1_1" parent="." instance=ExtResource( 3 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 10, 0, 10 )
[node name="area_1_2" parent="." instance=ExtResource( 6 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -9.9736, 0.0109801, -0.0108967 )
[node name="area_2_2" parent="." instance=ExtResource( 7 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -10, 0, 10 )
[node name="area_3_0" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 10, 0, -10 )
[node name="area_3_1" parent="." instance=ExtResource( 3 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -10 )
[node name="area_3_2" parent="." instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -10, 0, -10 )
[node name="map" type="Spatial" parent="."]

View file

@ -0,0 +1,21 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://scenes/player/creature_root.gd" type="Script" id=1]
[ext_resource path="res://assets/creatures/arche/arche.tscn" type="PackedScene" id=2]
[sub_resource type="CylinderShape" id=1]
height = 0.1
[node name="spatial" type="KinematicBody"]
script = ExtResource( 1 )
[node name="collision_shape" type="CollisionShape" parent="."]
shape = SubResource( 1 )
[node name="arche" parent="collision_shape" instance=ExtResource( 2 )]
[node name="camera_tps" type="Camera" parent="."]
transform = Transform( -1, 8.74228e-08, -5.0822e-21, 8.74228e-08, 1, -8.74228e-08, -7.64274e-15, -8.74228e-08, -1, 0, 1.23455, -1.8659 )
[node name="camera_fps" type="Camera" parent="."]
transform = Transform( -1, 8.74228e-08, 0, 8.74228e-08, 1, -8.74228e-08, -7.64274e-15, -8.74228e-08, -1, 0, 1.5747, 0.453716 )

View file

@ -0,0 +1,23 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://assets/creatures/isidor/isidor.tscn" type="PackedScene" id=1]
[ext_resource path="res://scenes/player/creature_root.gd" type="Script" id=2]
[sub_resource type="CylinderShape" id=1]
radius = 0.5
height = 0.1
[node name="spatial" type="KinematicBody"]
script = ExtResource( 2 )
[node name="collision_shape" type="CollisionShape" parent="."]
shape = SubResource( 1 )
[node name="isidor" parent="collision_shape" instance=ExtResource( 1 )]
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 0, 0 )
[node name="camera_tps" type="Camera" parent="."]
transform = Transform( -1, 8.74228e-08, -5.0822e-21, 8.74228e-08, 1, -8.74228e-08, -7.64274e-15, -8.74228e-08, -1, 0, 1.23455, -1.8659 )
[node name="camera_fps" type="Camera" parent="."]
transform = Transform( -1, 8.74228e-08, -5.0822e-21, 8.74228e-08, 1, -8.74228e-08, -7.64274e-15, -8.74228e-08, -1, 0, 1.5747, 0.453716 )

View file

@ -1,28 +1,13 @@
extends KinematicBody
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var rotation_speed_factor = 0.01
var move_speed = 2.5
var run_speed = 5.0
var max_speed = 12.0
export var gravity = -9.0
var animation_walk = "_bip01_ca_female_march"
var animation_run = "_bip01_ca_female_run"
var animation_scan_loop = "_bip01_ca_female_scanne_loop"
var animation_teleport_loop = "_bip01_ca_female_teleporte_loop"
extends CreatureRoot
#extends KinematicBody
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
animation_walk = "_bip01_ca_female_march"
animation_run = "_bip01_ca_female_run"
animation_scan_loop = "_bip01_ca_female_scanne_loop"
animation_teleport_loop = "_bip01_ca_female_teleporte_loop"
func get_animation_idle():
return "_bip01_ca_female_idle"

View file

@ -0,0 +1,92 @@
extends KinematicBody
class_name CreatureRoot
var animation_walk = "march"
var animation_run = "run"
var animation_scan_loop = "scanne_loop"
var animation_teleport_loop = "teleporte_loop"
var rotation_speed_factor = 0.01
var move_speed = 2.5
var run_speed = 5.0
var max_speed = 12.0
export var gravity = -9.0
var animation_object:AnimationPlayer = null
var orientation = 0.0
var direction = Vector3.ZERO
var velocity = Vector3.ZERO
var rotatex = 0.0
var move_run: bool = false
var move_toggle_run: bool = false
enum ACTION {
idle,
walk,
run,
scan,
teleport,
}
var current_action = ACTION.idle
func search_animation( obj ) -> bool:
var ret:bool = false
for i in obj.get_children():
if i.get_name() == "AnimationPlayer":
animation_object = i
return true
else:
ret = search_animation(i)
if ret == true:
return ret
return false
func update_blend_shapes( obj , param):
#blend_shapes = {}
update_blend_shapes_step(obj, param, "")
pass
func update_blend_shapes_step( obj, param, father = "" ):
for i in obj.get_children():
var root = father + str(i.name) + "."
if i is MeshInstance:
for key in i.get_property_list():
if key.name.substr(0, 13) == "blend_shapes/":
var blend = key.name.substr(13)
if param.has(blend):
i.set( "blend_shapes/"+blend, param[blend] )
update_blend_shapes_step( i, param, root)
func get_animation_idle():
# Possibility to have a multiple idle animation and select one
return "idle"
# Called when the node enters the scene tree for the first time.
func _ready():
current_action = ACTION.idle
search_animation( self )
launch_animation_idle()
func launch_animation_idle():
var idlename = self.get_animation_idle()
animation_object.play( idlename )
animation_object.connect("animation_finished", self, "_on_animation_finished")
func _on_animation_finished(anim_name):
Config.msg_debug( "{" + self.name + "} Animation finished:" + anim_name)
animation_object.play( anim_name )
func update_animation(action, anim_name):
# Change animation if we need
if current_action != action:
current_action = action
animation_object.play( anim_name )

View file

@ -64,7 +64,7 @@ func update_animation(action, anim_name):
func _on_AnimationPlayer_animation_finished(anim_name):
Config.msg_debug("Animation finished:" + anim_name)
Config.msg_debug( "{" + self.name + "} Animation finished:" + anim_name)
animation_object.play( anim_name )
@ -208,3 +208,5 @@ func _input( event ):
$creature/camera_fps.make_current()
else:
$creature/camera_tps.make_current()
elif event.is_action_pressed("menu"):
get_tree().quit()