Itween Path change speed
Hi, I'm making a bicycle simulation. It is made using Arduino and Unity. The bike speed measured at Arduino is transmitted to Unity. and I want to change the speed in itween path in real time. What should I do?
using UnityEngine; using System.Collections; using System.IO.Ports;
public class asdasdasd : MonoBehaviour { SerialPort sp = new SerialPort("COM3", 9600); //set Serial port string bikeSpeed;
void Start () {
sp.Open(); //Serial port open
sp.ReadTimeout = 1; //set Serial timeout
}
// Update is called once per frame
void Update () {
if (sp.IsOpen)
{
try
{
sp.Write("s"); //send start data
bikeSpeed = sp.ReadLine();
print(bikeSpeed);
float chbikespeed = float.Parse(bikeSpeed);
Debug.Log(bikeSpeed);
transform.Translate(Vector3.forward * Time.deltaTime * chbikespeed);
}
catch (System.Exception) { }
}
}
}
using UnityEngine; using System.Collections; using System.IO.Ports;
public class MoveBike : MonoBehaviour { SerialPort sp = new SerialPort("COM3", 9600); //set Serial port
// Use this for initialization
void Start () {
iTween.MoveTo(gameObject, iTween.Hash("path", iTweenPath.GetPath("Path1"), "orienttopath", true, "speed", 10));
}
// Update is called once per frame
void Update () {
}
}
Your answer
Follow this Question
Related Questions
How to change the speed of a runing iTween as I desired? 0 Answers
iTween Switching Paths 0 Answers
iTween camera fade NOT fading UI canvas 0 Answers
Timeline preview and iTween: iTween scripts getting added to objects in the editor 0 Answers
iTween: show a loading text right after CameraFadeTo has turned the screen black 0 Answers