跟着官方文档做教学案例,然后有时候前几步还运行的好好的,加了一两行动画代码就会报错这个。即使是删掉重新build还是依然报错这个,不知道怎么解决了,unity难民大哭
以下是代码
using Godot;
using System;
using System.Security.Cryptography.X509Certificates;
public partial class player : Area2D
{
[Export]
public int speed = 30;
public Vector2 direction;
private Vector2 screenSize;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
screenSize = GetViewportRect().Size;//获取屏幕大小且赋值
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
var vinput = Input.GetAxis("move_up", "move_down");
var hinput = Input.GetAxis("move_left", "move_right");
direction = new Vector2(hinput, vinput);
Position = new Vector2(
x: Mathf.Clamp(Position.X, 0, screenSize.X),
y: Mathf.Clamp(Position.Y, 0, screenSize.Y));
Position += direction.Normalized()*speed*(float)delta;
}
}
以下是代码
using Godot;
using System;
using System.Security.Cryptography.X509Certificates;
public partial class player : Area2D
{
[Export]
public int speed = 30;
public Vector2 direction;
private Vector2 screenSize;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
screenSize = GetViewportRect().Size;//获取屏幕大小且赋值
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
var vinput = Input.GetAxis("move_up", "move_down");
var hinput = Input.GetAxis("move_left", "move_right");
direction = new Vector2(hinput, vinput);
Position = new Vector2(
x: Mathf.Clamp(Position.X, 0, screenSize.X),
y: Mathf.Clamp(Position.Y, 0, screenSize.Y));
Position += direction.Normalized()*speed*(float)delta;
}
}