Search Unity

Rigid Body movepostion interpolate not smooth

Discussion in 'Physics' started by AlcoleponeHome, Aug 10, 2021.

  1. AlcoleponeHome

    AlcoleponeHome

    Joined:
    Jun 9, 2018
    Posts:
    47
    I have a simple project with a rigidbody sphere. this script is attached. When Space is pressed time slow's down. The rigid body has interpolate switched on, but the spheres movement is still only updated on the now reduced fixed update, looking stuttery. Should i expect the rigid body interpolate to smooth out this motion?

    Code (CSharp):
    1. public class Projectile : MonoBehaviour {
    2.     Vector3 movement;
    3.     Rigidbody projectileRigidbody;
    4.     public float speed = 6f;
    5.    
    6.     // Use this for initialization
    7.     void Awake ()
    8.     {
    9.             projectileRigidbody = GetComponent<Rigidbody>();
    10.     }
    11.  
    12.    
    13.     // Update is called once per frame
    14.     void FixedUpdate()
    15.     {
    16.         Move();
    17.         if (Input.GetKeyDown("space"))
    18.         {
    19.             Time.timeScale = Time.timeScale == 0.01f ? 1 : 0.01f;
    20.         }
    21.     }
    22.  
    23.     void Move()
    24.     {
    25.         movement = transform.forward * speed * Time.deltaTime;
    26.         projectileRigidbody.MovePosition(transform.position + movement);
    27.    
    28.     }    
    29. }