- Home /
Question by
Trollist843 · Dec 31, 2014 at 10:41 AM ·
characterrotatetimespherical
LookAt becoming inaccurate over time
I have a player on a spherical world and he can move around the planet. I was able to make the player turn towards the sphere by rotating one of the its bones towards a cube. After moving around the cube for about 30 seconds, the player wouldn't be looking at the cube, but somewhat close. Help please.
void Update() {
float distanceToPlane = Vector3.Dot(transform.up, GameObject.Find("Cube").transform.position - transform.position);
Vector3 planePoint = GameObject.Find("Cubed").transform.position - transform.up * distanceToPlane;
holder.LookAt(planePoint, transform.up);
}
void LateUpdate() {
spine.localEulerAngles = new Vector3(360-holder.rotation.eulerAngles.y,0f,0f);
//I put 360- because it was reflected for some reason
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613175207im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Make a character rotate around a point. 1 Answer
How can i make my simple character controller rotate? 0 Answers
Digital clock 1 Answer
Rotate 3D character 1 Answer
Character Rotate Properly 2 Answers