Quantcast
Channel: Latest Questions by Scion
Viewing all articles
Browse latest Browse all 4

How do I rotate to a custom Vector3 variable?

$
0
0
I'm Trying to figure out how to rotate to a specific rotation that is read via serial. The problem when running the code the object rotates as it should then slowly by itself rotates back? How do I fix this? I could be over complicating it basically I'd like to rotate my object to a vector that consists of Vector3(rotx,roty,rotz) and update that depending on the input from y device, but I cant seem to do it. public void getGyro() { string value = stream.ReadLine(); //Read the information string[] vec3 = value.Split(','); //returns a 3 part value (12,30,18) if(vec3[0] != "" && vec3[1] != "" && vec3[2] != "") //Check all values are recieved { nroty = int.Parse(vec3[0]); //new rot y nrotx = int.Parse(vec3[1]); //new rot x nrotz = int.Parse(vec3[2]); //new rot z print(vec3[0] + "," + vec3[1] + "," +vec3[2]); //rot = new Vector3(float.Parse(vec3[0]),float.Parse(vec3[1]),float.Parse(vec3[2])); transform.rotation = Quaternion.Slerp(transform.rotation,Quaternion.Euler(nroty,nrotz,nrotx),Time.deltaTime*1); stream.BaseStream.Flush(); //Clear the serial information so we assure we get new information. } }

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>