Question by
anaSTHENIS · Mar 14, 2021 at 09:23 PM ·
collidergameobjectsdisappear
Every Time i click Play my Wheels disappear!
Well the problem is that every time when i click play my wheels from a car disappear (as you can see in the screenshots) from some reason and i don't know what is the problem. I checked everything a lot of times and i cannot figure out what is the problem.
This is the script that i am using.
###################### public class Car : MonoBehaviour
{
public WheelCollider wheelColliderLeftFront;
public WheelCollider wheelColliderRightFront;
public WheelCollider wheelColliderLeftBack;
public WheelCollider wheelColliderRightBack;
public Transform wheelLeftFront;
public Transform wheelRightFront;
public Transform wheelLeftBack;
public Transform wheelRightBack;
public float motorTorque = 100f;
public float maxSteer = 20f;
void FixedUpdate()
{
wheelColliderLeftBack.motorTorque = Input.GetAxis("Vertical") * motorTorque;
wheelColliderRightBack.motorTorque = Input.GetAxis("Vertical") * motorTorque;
wheelColliderLeftFront.steerAngle = Input.GetAxis("Horizontal") * maxSteer;
wheelColliderRightFront.steerAngle = Input.GetAxis("Horizontal") * maxSteer;
}
void Update()
{
var pos = Vector3.zero;
var rot = Quaternion.identity;
wheelColliderLeftFront.GetWorldPose(out pos, out rot);
wheelLeftFront.position = pos;
wheelLeftFront.rotation = rot;
wheelColliderRightFront.GetWorldPose(out pos, out rot);
wheelRightFront.position = pos;
wheelRightFront.rotation = rot * Quaternion.Euler(0,180,0);
wheelColliderLeftBack.GetWorldPose(out pos, out rot);
wheelLeftBack.position = pos;
wheelLeftBack.rotation = rot;
wheelColliderRightBack.GetWorldPose(out pos, out rot);
wheelRightBack.position = pos;
wheelRightBack.rotation = rot * Quaternion.Euler(0, 180, 0);
}
}
screenshot-2021-03-14-062507.png
(223.3 kB)
screenshot-2021-03-14-062444.png
(210.6 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613030644im_/https://answers.unity.com/themes/thub/images/avi.jpg)