Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | catafest |
How can solve this issue?
I create a scene with a sprite player and I add this scene to default scene.
I add the C# script to the sprite player:
I got this error:
error CS0103: The name 'KEY_A' does not exist in the current context
This is my script player:
using Godot;
using System;
public class Player : KinematicBody2D
{
[Export]
private Vector2 motion = new Vector2(0, 100);
// Member variables here, example:
// private int a = 2;
// private string b = "textvar";
public override void _Ready()
{
// Called every time the node is added to the scene.
// Initialization here
GD.Print("Hello");
}
public override void _PhysicsProcess(float delta)
{
MoveAndCollide(motion * delta);
}
public override void _Input(InputEvent ev)
{
if (ev is InputEventMouse)
{
var mouseEvent = (InputEventMouse)ev;
Vector2 mousePos = mouseEvent.Position;
}
else if (ev is InputEventKey)
{
var keyEvent = (InputEventKey)ev;
bool aPressed = keyEvent.Pressed && keyEvent.Scancode == KEY_A;
}
}
}