From 114c8045ebe5ab694255f5e21ec571d4dc9f37fc Mon Sep 17 00:00:00 2001 From: vaporvee Date: Sat, 10 Dec 2022 21:35:20 +0100 Subject: [PATCH] resized player and player collision --- scenes/player.tscn | 11 +++++++---- scenes/worlds/first_world.tscn | 2 +- src/scene-scripts/player.cs | 9 +++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/scenes/player.tscn b/scenes/player.tscn index 3845394..c9c7e2d 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -12,18 +12,21 @@ animations = [{ }] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_38v5o"] -radius = 43.0 -height = 132.0 +radius = 18.057 +height = 56.0051 [node name="player" type="CharacterBody2D"] process_mode = 1 script = ExtResource("1_qehox") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +position = Vector2(-0.0625, -17.0625) +scale = Vector2(0.733398, 0.733398) frames = SubResource("SpriteFrames_2x1cy") [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -position = Vector2(0, 1) +position = Vector2(0, 12) +rotation = 1.57345 shape = SubResource("CapsuleShape2D_38v5o") [node name="Camera2D" type="Camera2D" parent="."] @@ -31,6 +34,6 @@ current = true zoom = Vector2(0.8, 0.8) [node name="ray_cast_2d" type="RayCast2D" parent="."] -target_position = Vector2(0, 100) +target_position = Vector2(0, 64) collision_mask = 2 collide_with_areas = true diff --git a/scenes/worlds/first_world.tscn b/scenes/worlds/first_world.tscn index 536490c..94a7785 100644 --- a/scenes/worlds/first_world.tscn +++ b/scenes/worlds/first_world.tscn @@ -15,4 +15,4 @@ tile_set = ExtResource("2_kvjhj") cell_quadrant_size = 64 format = 2 layer_0/z_index = 1 -layer_0/tile_data = PackedInt32Array(65535, 0, 0, 0, 0, 0, 1, 0, 0, 65534, 0, 0, 65533, 0, 0, -3, 0, 0, -2, 0, 0, -1, 0, 0, -65536, 0, 0, -65535, 0, 0, 65529, 1, 65536, 65541, 1, 65536, -196605, 1, 65536, 196603, 1, 65536) +layer_0/tile_data = PackedInt32Array(1, 0, 0, 65533, 0, 0, -3, 0, 0, -65535, 0, 0, 65529, 1, 65536, 65541, 1, 65536, -196605, 1, 65536, 196603, 1, 65536, -196603, 1, 65536, -196600, 1, 65536) diff --git a/src/scene-scripts/player.cs b/src/scene-scripts/player.cs index 053c530..b882ec8 100644 --- a/src/scene-scripts/player.cs +++ b/src/scene-scripts/player.cs @@ -24,10 +24,11 @@ public partial class player : CharacterBody2D public override void _Process(double delta) { //set ray_cast target position - if (Input.IsActionJustPressed("move_right")) GetNode("ray_cast_2d").TargetPosition = new Vector2(100, 0); - if (Input.IsActionJustPressed("move_left")) GetNode("ray_cast_2d").TargetPosition = new Vector2(-100, 0); - if (Input.IsActionJustPressed("move_down")) GetNode("ray_cast_2d").TargetPosition = new Vector2(0, 100); - if (Input.IsActionJustPressed("move_up")) GetNode("ray_cast_2d").TargetPosition = new Vector2(0, -100); + int raylength = 64; + if (Input.IsActionJustPressed("move_right")) GetNode("ray_cast_2d").TargetPosition = new Vector2(raylength, 0); + if (Input.IsActionJustPressed("move_left")) GetNode("ray_cast_2d").TargetPosition = new Vector2(-raylength, 0); + if (Input.IsActionJustPressed("move_down")) GetNode("ray_cast_2d").TargetPosition = new Vector2(0, raylength); + if (Input.IsActionJustPressed("move_up")) GetNode("ray_cast_2d").TargetPosition = new Vector2(0, -raylength); //call event in raycasted object if (Input.IsActionJustPressed("ui_accept") && GetNode("ray_cast_2d").IsColliding())