- Home /
Question by
ZWLSOFTWARE · May 31, 2020 at 07:33 PM ·
physicscubewheelcollider
simple thing I can't get right (see picture)
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;
}
}
}
pjvkbu.png
(104.7 kB)
Comment
Your answer
Follow this Question
Related Questions
Help: Shooting a cube 1 Answer
Wheel collider physics - something I'm missing? 0 Answers
How is wheelCollider RPM calculated exactly? 1 Answer
Wheel colliders take 0 force to compress, decompress instantly 0 Answers
WheelCollider Grip 3 Answers