diff --git a/Enemies/Frog.gd b/Enemies/Frog.gd index 60e904c..abd9027 100644 --- a/Enemies/Frog.gd +++ b/Enemies/Frog.gd @@ -13,34 +13,50 @@ var chase_flag = false # Not chasing the player if false func _on_player_detection_area_body_entered(body): if body.name == "Player": # If player is detected chase_flag = true + player = get_node("../../Player/Player") # Detect the player exiting area func _on_player_detection_area_body_exited(body): if body.name == "Player": # If player is detected chase_flag = false + player = get_node("../../Player/Player") func _physics_process(delta): # Add GRAVITY - velocity.y += GRAVITY * delta + self.velocity.y += GRAVITY * delta + var v2 = GRAVITY - 2 + print("DIRECTION: ") print(direction) + print("SELF: ", str(self.position)) # Check if we need to chase the player if chase_flag == true: # Determine direction to player player = get_node("../../Player/Player") + print("self pre: ", str(self.position)) print("pre: ", str(player.position)) - direction = (self.position-player.position).normalized() + + print("self pre N: ", str(self.position.normalized())) + print("pre N: ", str(player.position.normalized())) + direction = self.position-player.position.normalized() + print("self post: ", str(self.position)) print("pre: ", str(player.position)) + print("DIRECTIONNNN: ") + print(direction) + var d2 = self.position-player.position + print("DDDDDDD: ") + print(d2) if direction.x > 0: # On the right of the player get_node("AnimatedSprite2D").flip_h = true - velocity.x = direction.x * SPEED + #self.velocity.x = direction.x * SPEED elif direction.x < 0: # On the left of the player get_node("AnimatedSprite2D").flip_h = false - velocity.x = direction.x * SPEED + #self.velocity.x = direction.x * SPEED else: - velocity.x = 0 + self.velocity.x = 0 + get_node("AnimatedSprite2D").play("Idle") move_and_slide() diff --git a/Enemies/Frog.tscn b/Enemies/Frog.tscn index 0ddcc36..eb86ddc 100644 --- a/Enemies/Frog.tscn +++ b/Enemies/Frog.tscn @@ -77,6 +77,15 @@ animations = [{ }, { "duration": 1.0, "texture": SubResource("AtlasTexture_fhqta") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_837q8") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_837q8") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_837q8") }], "loop": true, "name": &"Idle", diff --git a/Player/Player.tscn b/Player/Player.tscn index e079023..e5cc4a5 100644 --- a/Player/Player.tscn +++ b/Player/Player.tscn @@ -114,8 +114,7 @@ animations = [{ "speed": 5.0 }] -[sub_resource type="Animation" id="Animation_iix2o"] -length = 0.5 +[sub_resource type="Animation" id="Animation_jb2vn"] tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true @@ -126,7 +125,7 @@ tracks/0/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), "update": 1, -"values": [&"Jump"] +"values": [&"Climb"] } tracks/1/type = "value" tracks/1/imported = false @@ -135,14 +134,13 @@ tracks/1/path = NodePath("AnimatedSprite2D:frame") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), +"times": PackedFloat32Array(0, 0.1, 0.2), +"transitions": PackedFloat32Array(1, 1, 1), "update": 1, -"values": [0] +"values": [0, 1, 2] } -[sub_resource type="Animation" id="Animation_ym81p"] -length = 0.6 +[sub_resource type="Animation" id="Animation_bi1k4"] tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true @@ -153,7 +151,7 @@ tracks/0/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), "update": 1, -"values": [&"Run"] +"values": [&"Crouch"] } tracks/1/type = "value" tracks/1/imported = false @@ -162,13 +160,14 @@ tracks/1/path = NodePath("AnimatedSprite2D:frame") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/keys = { -"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5), -"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1), +"times": PackedFloat32Array(0, 0.1), +"transitions": PackedFloat32Array(1, 1), "update": 1, -"values": [0, 1, 2, 3, 4, 5] +"values": [0, 1] } -[sub_resource type="Animation" id="Animation_bi1k4"] +[sub_resource type="Animation" id="Animation_oka38"] +resource_name = "Fall" tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true @@ -179,7 +178,7 @@ tracks/0/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), "update": 1, -"values": [&"Crouch"] +"values": [&"Jump"] } tracks/1/type = "value" tracks/1/imported = false @@ -188,13 +187,13 @@ tracks/1/path = NodePath("AnimatedSprite2D:frame") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/keys = { -"times": PackedFloat32Array(0, 0.1), -"transitions": PackedFloat32Array(1, 1), +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), "update": 1, -"values": [0, 1] +"values": [1] } -[sub_resource type="Animation" id="Animation_jb2vn"] +[sub_resource type="Animation" id="Animation_2d1hq"] tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true @@ -205,7 +204,7 @@ tracks/0/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), "update": 1, -"values": [&"Climb"] +"values": [&"Hurt"] } tracks/1/type = "value" tracks/1/imported = false @@ -214,13 +213,16 @@ tracks/1/path = NodePath("AnimatedSprite2D:frame") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/keys = { -"times": PackedFloat32Array(0, 0.1, 0.2), -"transitions": PackedFloat32Array(1, 1, 1), +"times": PackedFloat32Array(0, 0.1), +"transitions": PackedFloat32Array(1, 1), "update": 1, -"values": [0, 1, 2] +"values": [0, 1] } -[sub_resource type="Animation" id="Animation_2d1hq"] +[sub_resource type="Animation" id="Animation_7k72r"] +resource_name = "Idle" +length = 0.7 +loop_mode = 1 tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true @@ -231,7 +233,7 @@ tracks/0/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), "update": 1, -"values": [&"Hurt"] +"values": [&"Idle"] } tracks/1/type = "value" tracks/1/imported = false @@ -240,16 +242,14 @@ tracks/1/path = NodePath("AnimatedSprite2D:frame") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/keys = { -"times": PackedFloat32Array(0, 0.1), -"transitions": PackedFloat32Array(1, 1), +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3), +"transitions": PackedFloat32Array(1, 1, 1, 1), "update": 1, -"values": [0, 1] +"values": [0, 1, 2, 3] } -[sub_resource type="Animation" id="Animation_7k72r"] -resource_name = "Idle" -length = 0.7 -loop_mode = 1 +[sub_resource type="Animation" id="Animation_iix2o"] +length = 0.5 tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true @@ -260,7 +260,7 @@ tracks/0/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), "update": 1, -"values": [&"Idle"] +"values": [&"Jump"] } tracks/1/type = "value" tracks/1/imported = false @@ -269,10 +269,10 @@ tracks/1/path = NodePath("AnimatedSprite2D:frame") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/keys = { -"times": PackedFloat32Array(0, 0.1, 0.2, 0.3), -"transitions": PackedFloat32Array(1, 1, 1, 1), +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), "update": 1, -"values": [0, 1, 2, 3] +"values": [0] } [sub_resource type="Animation" id="Animation_vstpm"] @@ -302,8 +302,8 @@ tracks/1/keys = { "values": [1] } -[sub_resource type="Animation" id="Animation_oka38"] -resource_name = "Fall" +[sub_resource type="Animation" id="Animation_ym81p"] +length = 0.6 tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true @@ -314,7 +314,7 @@ tracks/0/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), "update": 1, -"values": [&"Jump"] +"values": [&"Run"] } tracks/1/type = "value" tracks/1/imported = false @@ -323,10 +323,10 @@ tracks/1/path = NodePath("AnimatedSprite2D:frame") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1), "update": 1, -"values": [1] +"values": [0, 1, 2, 3, 4, 5] } [sub_resource type="AnimationLibrary" id="AnimationLibrary_0muhe"]