Vector3.Lerp not cooperating with me
my code is supposed to move smoothly between the values given by osc but it is not working
public var RemoteIP : String = "127.0.0.1"; //127.0.0.1 signifies a local host (if testing locally
public var SendToPort : int = 9000; //the port you will be sending from
public var ListenerPort : int = 8050; //the port you will be listening on
public var controller : Transform;
public var gameReceiver = "Cube"; //the tag of the object on stage that you want to manipulate
private var handler : Osc;
//VARIABLES YOU WANT TO BE ANIMATED
var yHeight : Transform; //the rotation around the y axis
public function Start ()
{
%|139399711_1|%
//make sure this game object has both UDPPackIO and OSC script attached
var udp : UDPPacketIO = GetComponent("UDPPacketIO");
udp.init(RemoteIP, SendToPort, ListenerPort);
%|545286837_4|%
handler.init(udp);
handler.SetAllMessageHandler(AllMessageHandler);
}
Debug.Log("Running");
function Update () {
var go = GameObject.Find(gameReceiver);
go.position = Vector3.Lerp(go.position, yHeight.position, Time.deltaTime * 5.0);
}
//These functions are called when messages are received
//Access values via: oscMessage.Values[0], oscMessage.Values[1], etc
public function AllMessageHandler(oscMessage: OscMessage){
var msgString = Osc.OscMessageToString(oscMessage); //the message and value combined
%|1209005537_10|%
%|-1456286723_12|%
%|1502732130_11|%
//FUNCTIONS YOU WANT CALLED WHEN A SPECIFIC MESSAGE IS RECEIVED
%|-1251670691_15|%
%|-1530650056_15|%
%|-181472846_17|%
%|1293305117_16|%
default:
break;
}
}
//FUNCTIONS CALLED BY MATCHING A SPECIFIC MESSAGE IN THE ALLMESSAGEHANDLER FUNCTION
public function Rotate(msgValue) : void //rotate the cube around its axis
{
yHeight.position = new Vector3(0,msgValue,0);
}
Comment