How can i make this objects movement a bit more “Slippery” so that it doesnt just stop immediately when a controller is let go? i have 0 on both my drags.
public class GunStarController : MonoBehaviour
{
public float speed;
public float tiltLeftRight;
public float tiltForwardBack;
public Boundary boundary;
public Rigidbody rigidbody;
private void FixedUpdate()
{
float moveHorizontal = SimpleInput.GetAxis("Horizontal");
float moveVertical = SimpleInput.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rigidbody.velocity = movement * speed;
}
If you want to do it manually, just lerp from the current velocity to the new velocity. You can still decide how quickly you’re lerping in various circumstances.
IDK what the SimpleInput is, but if it is a wrapper for the old Input class and it’s not the new one with reading in the FixedUpdate cycle, you should move out the input part into an Update function.
Cool , will give this a go. I notice when setting up movement for objects that sometimes it works naturally like this. Is it just the differences in setting up movement? transforms vs rigidbody’s?
If you use addforce and drag or whatnot, you can get some naturally slippery movement because in that case you are controlling the rigidbody indirectly using the physics engine. On the other hand, when you set the velocity explicitly like you’re doing now, you’re basically over-riding the physics engine and taking direct control for yourself, so it’s not slippery unless you make it slippery.
Neither approach is necessarily better or worse, it just depends on what you need.