using Godot; using System; using System.IO.Ports; public class pruebaMajo: Spatial { // Declare member variables here. Examples: // private int a = 2; // private string b = "text"; // Called when the node enters the scene tree for the first time. SerialPort mipuerto = new SerialPort("COM3",57600); public string [] valoresLeidos; public float anguloGrados; public float anguloRadianes; public override void _Ready() { mipuerto.Open(); mipuerto.ReadTimeout = 1; valoresLeidos = new string[2]; } // // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(float delta) { if(mipuerto.IsOpen) { try { string valor = mipuerto.ReadLine(); valoresLeidos = valor.Split(","); //GD.Print(valor); anguloGrados = (float.Parse(valoresLeidos[0])) -1.5F; anguloRadianes = anguloGrados*(Mathf.Pi/180); RotateZ((anguloRadianes*0.25f)*delta); //Translation = new Vector3(0,1,0) * delta ; //anslate(Transform.basis.x*(float.Parse(valoresLeidos[1]))*delta); GD.Print( "Ángulo " + valoresLeidos[0]); GD.Print("Aceleracion "+ valoresLeidos[1]); } catch { } } } }