new player avatar
This commit is contained in:
@@ -25,16 +25,13 @@ 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(64, 0);
|
||||
if (Input.IsActionJustPressed("move_left")) GetNode<RayCast2D>("ray_cast_2d").TargetPosition = new Vector2(-64, 0);
|
||||
if (Input.IsActionJustPressed("move_down")) GetNode<RayCast2D>("ray_cast_2d").TargetPosition = new Vector2(0, 64);
|
||||
if (Input.IsActionJustPressed("move_up")) GetNode<RayCast2D>("ray_cast_2d").TargetPosition = new Vector2(0, -64);
|
||||
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);
|
||||
|
||||
//call event in raycasted object
|
||||
if (Input.IsActionJustPressed("ui_accept") && GetNode<RayCast2D>("ray_cast_2d").IsColliding())
|
||||
{
|
||||
var raycastedObject = GetNode<RayCast2D>("ray_cast_2d").GetCollider();
|
||||
raycastedObject.Call("OnInteraction", playerName);
|
||||
}
|
||||
GetNode<RayCast2D>("ray_cast_2d").GetCollider().Call("OnInteraction", playerName);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user