made raycast smaller
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://ujfhvssvbgpg"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/scene-scripts/player.cs" id="1_qehox"]
|
||||
[ext_resource type="Texture2D" uid="uid://c3ep33iycax04" path="res://assets/textures/debug/dummy-player-normal.png" id="2_48656"]
|
||||
[ext_resource type="Texture2D" uid="uid://377657cxmdpa" path="res://assets/textures/debug/dummy-player-normal.png" id="2_48656"]
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_2x1cy"]
|
||||
animations = [{
|
||||
@@ -31,6 +31,6 @@ current = true
|
||||
zoom = Vector2(0.8, 0.8)
|
||||
|
||||
[node name="ray_cast_2d" type="RayCast2D" parent="."]
|
||||
target_position = Vector2(0, 128)
|
||||
target_position = Vector2(0, 100)
|
||||
collision_mask = 2
|
||||
collide_with_areas = true
|
||||
|
@@ -1,6 +1,5 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
public partial class player : CharacterBody2D
|
||||
{
|
||||
@@ -25,10 +24,10 @@ public partial class player : CharacterBody2D
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
//set ray_cast target position
|
||||
if (Input.IsActionJustPressed("move_right")) GetNode<RayCast2D>("ray_cast_2d").TargetPosition = new Vector2(128, 0);
|
||||
if (Input.IsActionJustPressed("move_left")) GetNode<RayCast2D>("ray_cast_2d").TargetPosition = new Vector2(-128, 0);
|
||||
if (Input.IsActionJustPressed("move_down")) GetNode<RayCast2D>("ray_cast_2d").TargetPosition = new Vector2(0, 128);
|
||||
if (Input.IsActionJustPressed("move_up")) GetNode<RayCast2D>("ray_cast_2d").TargetPosition = new Vector2(0, -128);
|
||||
if (Input.IsActionJustPressed("move_right")) GetNode<RayCast2D>("ray_cast_2d").TargetPosition = new Vector2(100, 0);
|
||||
if (Input.IsActionJustPressed("move_left")) GetNode<RayCast2D>("ray_cast_2d").TargetPosition = new Vector2(-100, 0);
|
||||
if (Input.IsActionJustPressed("move_down")) GetNode<RayCast2D>("ray_cast_2d").TargetPosition = new Vector2(0, 100);
|
||||
if (Input.IsActionJustPressed("move_up")) GetNode<RayCast2D>("ray_cast_2d").TargetPosition = new Vector2(0, -100);
|
||||
|
||||
//call event in raycasted object
|
||||
if (Input.IsActionJustPressed("ui_accept") && GetNode<RayCast2D>("ray_cast_2d").IsColliding())
|
||||
|
Reference in New Issue
Block a user