Strafing
This commit is contained in:
@@ -137,6 +137,18 @@ Throw={
|
||||
"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":88,"key_label":0,"unicode":120,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
StrafeLeft={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":4,"axis_value":1.0,"script":null)
|
||||
, 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":81,"key_label":0,"unicode":113,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
StrafeRight={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":5,"axis_value":1.0,"script":null)
|
||||
, 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":82,"key_label":0,"unicode":114,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[internationalization]
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -13,9 +13,10 @@ height = 2.8375
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_nwuwj"]
|
||||
height = 2.24425
|
||||
radius = 1.00578
|
||||
radius = 1.941
|
||||
|
||||
[node name="NPC" type="Node3D"]
|
||||
transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0, 0, 0)
|
||||
script = ExtResource("1_cpdf2")
|
||||
Dialogue = ExtResource("2_uo38w")
|
||||
|
||||
@@ -23,7 +24,6 @@ Dialogue = ExtResource("2_uo38w")
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0)
|
||||
gi_mode = 0
|
||||
pixel_size = 0.005
|
||||
billboard = 2
|
||||
texture_filter = 0
|
||||
texture = ExtResource("1_0r0wh")
|
||||
|
||||
@@ -16,6 +16,10 @@ namespace GameJamDungeon
|
||||
PlayerData PlayerData { get; }
|
||||
|
||||
public Vector3 GetGlobalInputVector();
|
||||
|
||||
public float GetLeftStrafeInputVector();
|
||||
|
||||
public float GetRightStrafeInputVector();
|
||||
}
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
@@ -139,8 +143,7 @@ namespace GameJamDungeon
|
||||
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
{
|
||||
var attackIsPressed = Input.IsActionJustPressed(GameInputs.Attack);
|
||||
if (attackIsPressed && !GameRepo.IsWithinDialogueSpace)
|
||||
if (Input.IsActionJustPressed(GameInputs.Attack))
|
||||
PlayerLogic.Input(new PlayerLogic.Input.Attack());
|
||||
}
|
||||
|
||||
@@ -176,7 +179,6 @@ namespace GameJamDungeon
|
||||
public Vector3 GetGlobalInputVector()
|
||||
{
|
||||
var rawInput = Input.GetVector(GameInputs.MoveLeft, GameInputs.MoveRight, GameInputs.MoveUp, GameInputs.MoveDown);
|
||||
|
||||
var input = new Vector3
|
||||
{
|
||||
X = rawInput.X,
|
||||
@@ -185,6 +187,18 @@ namespace GameJamDungeon
|
||||
return input with { Y = 0f };
|
||||
}
|
||||
|
||||
public float GetLeftStrafeInputVector()
|
||||
{
|
||||
var leftStrafe = Input.GetActionStrength(GameInputs.StrafeLeft);
|
||||
return leftStrafe;
|
||||
}
|
||||
|
||||
public float GetRightStrafeInputVector()
|
||||
{
|
||||
var rightStrafe = Input.GetActionStrength(GameInputs.StrafeRight);
|
||||
return rightStrafe;
|
||||
}
|
||||
|
||||
public void ThrowItem()
|
||||
{
|
||||
var itemScene = GD.Load<PackedScene>("res://src/items/throwable/ThrowableItem.tscn");
|
||||
|
||||
@@ -16,10 +16,12 @@ namespace GameJamDungeon
|
||||
var settings = Get<Settings>();
|
||||
|
||||
var rawInput = player.GetGlobalInputVector();
|
||||
var strafeLeftInput = player.GetLeftStrafeInputVector();
|
||||
var strafeRightInput = player.GetRightStrafeInputVector();
|
||||
|
||||
var transform = player.Transform;
|
||||
transform.Basis = new Basis(Vector3.Up, settings.RotationSpeed * -rawInput.X) * transform.Basis;
|
||||
var velocity = player.Basis * new Vector3(0, 0, rawInput.Z) * settings.MoveSpeed;
|
||||
var velocity = player.Basis * new Vector3(strafeRightInput - strafeLeftInput, 0, rawInput.Z) * settings.MoveSpeed;
|
||||
|
||||
if (Godot.Input.IsActionPressed(GameInputs.Sprint))
|
||||
velocity *= 3;
|
||||
|
||||
Reference in New Issue
Block a user