I have been trying out Unity 5.2 and I’ve noticed that I’m getting spikes from the physics processing that causes a moving object to stutter/jump.
The basic scene setup is:
A Plane that has been marked as static
A Cube that has a box collider, rigidbody and a script to move it
When I move the cube using the keyboard it jumps/stutter as it moves and I get big spikes on the physics side when this happens. I have tried this with the cube sitting on the plane, just above it and with the plane completely disabled, but the problem continues.
I have attached screenshots which show the spikes in the profiler and the components attached to the cube.
This is the movement code:
public class Movement : MonoBehaviour
{
public float MoveSpeed = 4.5f;
private Rigidbody _rigidbody;
private void Awake()
{
_rigidbody = GetComponent<Rigidbody>();
}
private void FixedUpdate()
{
Vector3 input = new Vector3(Input.GetAxisRaw("Horizontal"), 0f, Input.GetAxisRaw("Vertical"));
_rigidbody.position += input * MoveSpeed * Time.fixedDeltaTime;
_rigidbody.rotation = Quaternion.LookRotation(Vector3.RotateTowards(this.transform.forward, new Vector3(input.x, 0f, input.z), 6f * Time.fixedDeltaTime, 0f));
}
}
I am currently running Unity 5.2, an AMD HD7850 graphics card and Windows 10 x64.I never ran into this issues with 4.x or previous 5.x, so I’m unsure as to whether I’m missing something, whether it’s a Windows 10 issue or maybe a 5.2 issue.
Has anyone else experienced a problem similar to this?
I have upgraded from 5.2.1 to 5.2.1p1 and p2 and the problem still remains. I have just tried again, on 5.2, with a single cube and the move script and the issues is still the same.
I read somewhere that it is possible for the physics simulation to run multiple times to catch up with the frame rate, so I changed the physics time to 0.0166 as my monitor is running at 60hz, but this did not appear have any effect.
It is at the point where it is extremely difficult to test anything as characters are always stuttering as they move.
@elias_t Can you tell me what graphics card/OS/CPU you have, so I can compare to my PC? I’m trying to work out if it is a Unity issue or a issue with my hardware/setup. The thing is never had this issue when using Unity 5.0, but that was back on Windows 8.1.