using Godot; using System; using System.IO.Ports; public class dragon: 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 float velocidad; public Vector3 rotacionDragon; public Vector3 rotacion90; 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); Rotation = new Vector3(0,0,1)*(anguloGrados*0.005f) *delta; //RotateZ((anguloRadianes*0.25f)*delta); velocidad = (float.Parse(valoresLeidos[1]))* 0.05f; Translation += new Vector3(1,0,0) *(velocidad)* delta ; //anslate(Transform.basis.x*(float.Parse(valoresLeidos[1]))*delta); //GD.Print("Aceleracion "+ valoresLeidos[1]); } catch { } } } }