Vesna walking and idle animations work for all movement directions.
This commit is contained in:
Generated
-1
@@ -1 +0,0 @@
|
|||||||
Babushka
|
|
||||||
@@ -4,12 +4,11 @@ importer="scene"
|
|||||||
importer_version=1
|
importer_version=1
|
||||||
type="PackedScene"
|
type="PackedScene"
|
||||||
uid="uid://b3kyrsoobmkhp"
|
uid="uid://b3kyrsoobmkhp"
|
||||||
path="res://.godot/imported/best_house_blender.blend-ac89c74aef2f275bdf4b4baadee17c0c.scn"
|
valid=false
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://art/mockups/3d/best_house_blender.blend"
|
source_file="res://art/mockups/3d/best_house_blender.blend"
|
||||||
dest_files=["res://.godot/imported/best_house_blender.blend-ac89c74aef2f275bdf4b4baadee17c0c.scn"]
|
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[gd_scene load_steps=5 format=3 uid="uid://cgjc4wurbgimy"]
|
[gd_scene load_steps=5 format=3 uid="uid://cgjc4wurbgimy"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://b7vlkecrn0t5c" path="res://scripts/CSharp/Common/Inventory/InventoryUi.cs" id="1_6wusm"]
|
[ext_resource type="Script" uid="uid://hg7jay2kt441" path="res://scripts/CSharp/Common/Inventory/InventoryUi.cs" id="1_6wusm"]
|
||||||
[ext_resource type="Script" uid="uid://b2jhdxcrhtm2d" path="res://scripts/CSharp/Common/Inventory/InventoryTestScript.cs" id="3_exrk4"]
|
[ext_resource type="Script" uid="uid://b2jhdxcrhtm2d" path="res://scripts/CSharp/Common/Inventory/InventoryTestScript.cs" id="3_exrk4"]
|
||||||
[ext_resource type="Resource" uid="uid://datee0flk1e84" path="res://resources/items/pickaxe.tres" id="4_5fdxq"]
|
[ext_resource type="Resource" uid="uid://datee0flk1e84" path="res://resources/items/pickaxe.tres" id="4_5fdxq"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c7wqla0mbu3np" path="res://graphics/ui/babushka_ui_tmp_inventory_select.png" id="4_tiss4"]
|
[ext_resource type="Texture2D" uid="uid://c7wqla0mbu3np" path="res://graphics/ui/babushka_ui_tmp_inventory_select.png" id="4_tiss4"]
|
||||||
@@ -42,6 +42,7 @@ columns = 10
|
|||||||
[node name="SlotSelectContainer" type="Control" parent="SlotsContainer"]
|
[node name="SlotSelectContainer" type="Control" parent="SlotsContainer"]
|
||||||
custom_minimum_size = Vector2(1000, 100)
|
custom_minimum_size = Vector2(1000, 100)
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
anchors_preset = 7
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
anchor_top = 1.0
|
anchor_top = 1.0
|
||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
|
|||||||
+5
-1
@@ -66,6 +66,10 @@ translation/id_counter=22
|
|||||||
translation/locales=["de", "en"]
|
translation/locales=["de", "en"]
|
||||||
text/autopauses={}
|
text/autopauses={}
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/size/always_on_top=true
|
||||||
|
|
||||||
[dotnet]
|
[dotnet]
|
||||||
|
|
||||||
project/assembly_name="Babushka"
|
project/assembly_name="Babushka"
|
||||||
@@ -129,7 +133,7 @@ interact={
|
|||||||
}
|
}
|
||||||
ui_inventory_open_close={
|
ui_inventory_open_close={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":73,"key_label":0,"unicode":105,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
ui_inventory_advance={
|
ui_inventory_advance={
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ _fieldParent = NodePath("../FieldParent")
|
|||||||
transform = Transform3D(1, 0, 0, 0, 0.618408, 0.785857, 0, -0.785857, 0.618408, -0.802612, 0, 4.73262)
|
transform = Transform3D(1, 0, 0, 0, 0.618408, 0.785857, 0, -0.785857, 0.618408, -0.802612, 0, 4.73262)
|
||||||
|
|
||||||
[node name="BaseField" parent="." instance=ExtResource("2_72r8y")]
|
[node name="BaseField" parent="." instance=ExtResource("2_72r8y")]
|
||||||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0.001, 0)
|
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0.0574723, 0)
|
||||||
|
|
||||||
[node name="HoePickup" parent="." instance=ExtResource("4_r4sre")]
|
[node name="HoePickup" parent="." instance=ExtResource("4_r4sre")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, -1.06581e-14, 0, 1.06581e-14, 1, -4.327, 1.5, -3.447)
|
transform = Transform3D(1, 0, 0, 0, 1, -1.06581e-14, 0, 1.06581e-14, 1, -4.327, 1.5, -3.447)
|
||||||
@@ -53,5 +53,9 @@ shape = SubResource("SphereShape3D_0ptl4")
|
|||||||
[node name="FieldParent" type="Node3D" parent="."]
|
[node name="FieldParent" type="Node3D" parent="."]
|
||||||
|
|
||||||
[node name="Inventory" parent="." instance=ExtResource("5_obfp0")]
|
[node name="Inventory" parent="." instance=ExtResource("5_obfp0")]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[connection signal="Interacted" from="HoePickup" to="HoePickup/SpriteSwitcher Hoe" method="SwitchState"]
|
||||||
|
[connection signal="Switch" from="HoePickup/SpriteSwitcher Hoe" to="Player3d" method="ActivateHoe"]
|
||||||
|
|
||||||
[editable path="HoePickup"]
|
[editable path="HoePickup"]
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
||||||
@@ -17,21 +18,25 @@ public partial class Player3D : CharacterBody3D
|
|||||||
[Export] private AnimatedSprite3D[] _backSpritesAnimated;
|
[Export] private AnimatedSprite3D[] _backSpritesAnimated;
|
||||||
|
|
||||||
private bool _sideFlipped;
|
private bool _sideFlipped;
|
||||||
|
private Vector2 _lastDirection;
|
||||||
|
|
||||||
public override void _PhysicsProcess(double delta)
|
public override void _PhysicsProcess(double delta)
|
||||||
{
|
{
|
||||||
var inputDir = Input.GetVector("move_left", "move_right", "move_up", "move_down");
|
var inputDir = Input.GetVector("move_left", "move_right", "move_down", "move_up");
|
||||||
if (inputDir == Vector2.Zero)
|
if (inputDir == Vector2.Zero)
|
||||||
|
{
|
||||||
|
if(_lastDirection != Vector2.Zero)
|
||||||
|
SwitchIdleSprites();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MoveOnInput(inputDir, delta);
|
MoveOnInput(inputDir, delta);
|
||||||
SwitchSprites(inputDir);
|
SwitchMovementSprites(inputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MoveOnInput(Vector2 inputDir, double delta)
|
private void MoveOnInput(Vector2 inputDir, double delta)
|
||||||
{
|
{
|
||||||
inputDir = inputDir.Rotated(-_camera.GlobalRotation.Y);
|
var direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y * (-1))).Normalized();
|
||||||
var direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
|
|
||||||
if (direction != Vector3.Zero)
|
if (direction != Vector3.Zero)
|
||||||
Velocity = new Vector3(direction.X * _speed * (float) delta * Scale.X, Velocity.Y, direction.Z * _speed * (float) delta * Scale.Z);
|
Velocity = new Vector3(direction.X * _speed * (float) delta * Scale.X, Velocity.Y, direction.Z * _speed * (float) delta * Scale.Z);
|
||||||
else
|
else
|
||||||
@@ -40,20 +45,34 @@ public partial class Player3D : CharacterBody3D
|
|||||||
MoveAndSlide();
|
MoveAndSlide();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SwitchSprites(Vector2 inputDir)
|
private void SwitchIdleSprites()
|
||||||
|
{
|
||||||
|
if (_lastDirection.X != 0)
|
||||||
|
{
|
||||||
|
ActivateSprite(0, false, true, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_lastDirection.Y <= 0.0f)
|
||||||
|
ActivateSprite(0, true, false, false);
|
||||||
|
|
||||||
|
if(_lastDirection.Y > 0.0f)
|
||||||
|
ActivateSprite(0, false, false, true);
|
||||||
|
|
||||||
|
_lastDirection = Vector2.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SwitchMovementSprites(Vector2 inputDir)
|
||||||
{
|
{
|
||||||
float X = inputDir.X;
|
float X = inputDir.X;
|
||||||
float Y = inputDir.Y;
|
float Y = inputDir.Y;
|
||||||
|
|
||||||
if (X == 0.0 && Y == 0.0)
|
_lastDirection = new Vector2(X, Y);
|
||||||
{
|
Debug.Print(_lastDirection.ToString());
|
||||||
ActivateFrontSpriteIdle(0, true, false, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (X != 0)
|
if (X != 0)
|
||||||
{
|
{
|
||||||
ActivateFrontSpriteIdle(1, false, true, false);
|
ActivateSprite(1, false, true, false);
|
||||||
|
|
||||||
if (X > 0.0f)
|
if (X > 0.0f)
|
||||||
{
|
{
|
||||||
@@ -74,20 +93,19 @@ public partial class Player3D : CharacterBody3D
|
|||||||
|
|
||||||
if (Y != 0)
|
if (Y != 0)
|
||||||
{
|
{
|
||||||
if (Y < 0.0f)
|
|
||||||
{
|
|
||||||
ActivateFrontSpriteIdle(1, false, false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Y > 0.0f)
|
if (Y > 0.0f)
|
||||||
{
|
{
|
||||||
ActivateFrontSpriteIdle(0, true, false, false);
|
ActivateSprite(1, false, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Y < 0.0f)
|
||||||
|
{
|
||||||
|
ActivateSprite(1, true, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ActivateFrontSpriteIdle(int index, bool frontActive, bool sideActive, bool backActive)
|
private void ActivateSprite(int index, bool frontActive, bool sideActive, bool backActive)
|
||||||
{
|
{
|
||||||
DeactivateAll();
|
DeactivateAll();
|
||||||
_frontSpritesAnimated[index].Visible = frontActive;
|
_frontSpritesAnimated[index].Visible = frontActive;
|
||||||
|
|||||||
Reference in New Issue
Block a user