Код Arduino:
Код: Выделить всё
void setup() {
Serial.begin(9600);
}
void loop() {
int val=random(0,1);
if(val==1){
Serial.flush();
Serial.println(1);
}
else{
Serial.flush();
Serial.println(0);
}
}
delay(500);
}
Код: Выделить всё
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.IO.Ports;
using UnityEngine;
public class ard : MonoBehaviour
{
private SerialPort data_stream = new SerialPort("COM3", 9600);
public GameObject kid;
// Start is called before the first frame update
void Start()
{
data_stream.Open();
}
// Update is called once per frame
void Update()
{
if (data_stream.IsOpen) {
string val=data_stream.ReadLine();
if (val == "0") {
kid.GetComponent().Play("Standing Idle To Fight Idle");
}
else if(val == "1")
{
kid.GetComponent().Play("Fast Run");
}
}
}
}
Что мне нужно изменить, чтобы анимация стала плавной при приеме последовательных данных в качестве входных данных?
Подробнее здесь: https://stackoverflow.com/questions/785 ... -port-open