Le z-indexeur est là pour z-indexer tous ces petits gars
Quand il rentre en action il trouve si quelqu'un est en collision Et il prend la hauteur de cette personne et se place au dessus Il est comme ça le zindexeur, il est sans gêne
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
class_name Car
|
||||
extends CharacterBody2D
|
||||
|
||||
@export var debugLabel: Label
|
||||
@export var speed = 750 # How fast the car will move (pixels/sec).
|
||||
@onready var animation_tree := $AnimationTree
|
||||
@onready var state_machine := animation_tree.get("parameters/driving/playback") as AnimationNodeStateMachinePlayback
|
||||
@@ -18,8 +19,11 @@ func updateFacingDirectionInAnimationTree():
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
$ZIndexControler/ShapeCast2D.enabled = !$CollisionHorizontal.disabled
|
||||
|
||||
if (targetPosition != null):
|
||||
velocity = (targetPosition - position) * speed * delta;
|
||||
|
||||
move_and_slide()
|
||||
if velocity:
|
||||
last_facing_direction = velocity.normalized()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=33 format=3 uid="uid://bt1p311rn1h6q"]
|
||||
[gd_scene load_steps=35 format=3 uid="uid://bt1p311rn1h6q"]
|
||||
|
||||
[ext_resource type="Script" path="res://vehicules/car.gd" id="1_vkq5y"]
|
||||
[ext_resource type="PackedScene" uid="uid://brh7cqaxc13ie" path="res://zindex/ZIndexControler.tscn" id="3_iaqxo"]
|
||||
[ext_resource type="Texture2D" uid="uid://dq81e78eaild8" path="res://assest/vehicules/Car_classic_red_48x48.png" id="4_0kman"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_24r8n"]
|
||||
@@ -329,6 +330,47 @@ tracks/2/keys = {
|
||||
"values": [true]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_xch04"]
|
||||
resource_name = "idling_up"
|
||||
length = 0.1
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Car/Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [35]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Car/CollisionHorizontal:disabled")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [true]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Car/CollisionVertical:disabled")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [false]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_0uy2s"]
|
||||
resource_name = "opening_door_left"
|
||||
tracks/0/type = "value"
|
||||
@@ -407,47 +449,6 @@ tracks/2/keys = {
|
||||
"values": [true]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_xch04"]
|
||||
resource_name = "idling_up"
|
||||
length = 0.1
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Car/Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [35]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Car/CollisionHorizontal:disabled")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [true]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Car/CollisionVertical:disabled")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [false]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_10pc8"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_24r8n"),
|
||||
@@ -537,7 +538,7 @@ graph_offset = Vector2(80, -182)
|
||||
[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_5fwej"]
|
||||
|
||||
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_q5j17"]
|
||||
graph_offset = Vector2(-249.333, -55.3333)
|
||||
graph_offset = Vector2(-221.333, -11.3333)
|
||||
nodes/CarStates/node = SubResource("AnimationNodeStateMachine_tnex5")
|
||||
nodes/CarStates/position = Vector2(-133.333, 173.333)
|
||||
nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_5fwej")
|
||||
@@ -546,11 +547,15 @@ node_connections = [&"TimeScale", 0, &"CarStates", &"output", 0, &"TimeScale"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_l8rwt"]
|
||||
radius = 31.0
|
||||
height = 160.0
|
||||
height = 186.0
|
||||
|
||||
[node name="Car" type="CharacterBody2D"]
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_yiphh"]
|
||||
size = Vector2(240, 15)
|
||||
|
||||
[node name="Car" type="CharacterBody2D" node_paths=PackedStringArray("debugLabel")]
|
||||
motion_mode = 1
|
||||
script = ExtResource("1_vkq5y")
|
||||
debugLabel = NodePath("Label")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("4_0kman")
|
||||
@@ -569,7 +574,7 @@ tree_root = SubResource("AnimationNodeBlendTree_q5j17")
|
||||
advance_expression_base_node = NodePath("..")
|
||||
anim_player = NodePath("../AnimationPlayer")
|
||||
parameters/CarStates/driving/blend_position = Vector2(0.0425786, -0.23119)
|
||||
parameters/CarStates/idling/blend_position = Vector2(-0.000397921, -0.120715)
|
||||
parameters/CarStates/idling/blend_position = Vector2(-0.31635, 0.279753)
|
||||
parameters/TimeScale/scale = 1.0
|
||||
|
||||
[node name="CollisionHorizontal" type="CollisionShape2D" parent="."]
|
||||
@@ -581,3 +586,16 @@ shape = SubResource("CapsuleShape2D_l8rwt")
|
||||
position = Vector2(1, 2)
|
||||
rotation = -3.14159
|
||||
shape = SubResource("CapsuleShape2D_l8rwt")
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
offset_left = 72.0
|
||||
offset_top = -42.0
|
||||
offset_right = 112.0
|
||||
offset_bottom = -19.0
|
||||
|
||||
[node name="ZIndexControler" parent="." instance=ExtResource("3_iaqxo")]
|
||||
|
||||
[node name="ShapeCast2D" type="ShapeCast2D" parent="ZIndexControler"]
|
||||
position = Vector2(1, -13)
|
||||
shape = SubResource("RectangleShape2D_yiphh")
|
||||
target_position = Vector2(0, -46)
|
||||
|
||||
Reference in New Issue
Block a user