transform.position doesn't work correctly.
void SetCarToCheckPoint()
{
ChangeDriveMode(DriveModes.Parking);
transform.position = lastCheckpoint.transform.position;
}
So the above function sets my car's position to checkpoint's position. The function ChangeDriveMode() toggles the isKinematic flag of the rigidbody to on, so that it stops reacting to the physics engine, and then I try to set the position of the car to last saved checkpoint. But the 2nd line doesn't seem to work every time. The position doesn't change at all, and the code continues as everything was normal. And I'm not having any NullReference, because there's always a default checkpoint which is the spawn point of the car. I really can't figure it out. Why would something like transfrom.position wouldn't work.
Can anyone help me here? Thanks.
Are you sure lastCheckpoint updates correctly? Have you tried https://docs.unity3d.com/ScriptReference/Rigidbody-position.html?
@$$anonymous$$lockrent, Yes the lastCheckpoint updates correctly. Every time a level starts, it is set to the start position by default. I've never used Rigidbody.position ever. Seems helpful. Let me try that. I really appreciate your help. Thank you. :D