Hi, I am facing a problem where my object(car) is being stopped every time it collides with an other object. I have a platform and a car on top of it and both the car and platform is turning(the car only turns when in contact with the platform). So if I stand in front of the car(or just put a cube in the way) the car suddenly stops like anything would do, but when I step away it doesn’t rotate any more. In the scene editor if I apply a quick force in the up direction the car turns again. If this wold help I am making a car that rotates on an platform for a car showroom.
This is the code attached to the car:
using UnityEngine;
using System.Collections;
public class TurnCar : MonoBehaviour {
private bool trigger;
private float turnSpeed = 10;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if(trigger == true)
{
transform.Rotate (Vector3.up, turnSpeed*Time.deltaTime);
}
}
void OnCollisionEnter(Collision col)
{
if (col.collider.tag == "TurnTable")
{
trigger = true;
}
else
trigger = false;
}
}
And this is the code for the platform:
using UnityEngine;
using System.Collections;
public class TurnObjectStand : MonoBehaviour {
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
transform.Rotate (Vector3.up, 10f*Time.deltaTime);
}
}
Any solutions, I have one but it may be unnesesary and can cause problems The solution I have in mind: So the car stops turning when it hits the player or object, what if I apply a small force upwards that will lift it about 3cm(or an inch) once the player steps of the platform so that the car can rotate again. But it still doesn’t solve the problem that why the car stops moving
Thank you