Quantcast
Channel: Questions in topic: "wheelcollider"
Viewing all articles
Browse latest Browse all 490

simple thing I can't get right (see picture)

$
0
0
Hi all, Im trying to make a cube on 2 wheels. I'm trying to get the cube balanced but it gives me weird physics. I know I can disable rotation in the rigidbody but I don't want it like that. Can someone help me out? public class stabalizeRobo : MonoBehaviour { public float x; Vector3 r; Vector3 a; public float speed; private void FixedUpdate() { x = transform.localEulerAngles.x; r = new Vector3(transform.rotation.x,0,0); a = new Vector3(0,0,0); if (x > 256f) x = (x * -1f) + 360f; else x = -x; if ( x >= 0) { Debug.Log("over 0"); transform.eulerAngles -= Vector3.Lerp(r, a, 100f * -Time.deltaTime) * -speed * Time.deltaTime; } if( x <= 0) { Debug.Log("under 0"); transform.eulerAngles -= Vector3.Lerp(r, a, 100f * -Time.deltaTime) * speed * Time.deltaTime; } } }

Viewing all articles
Browse latest Browse all 490

Trending Articles



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