Hello. I’m having issues getting my rigidbody character to move smoothly. I’ve tried the interpolate option on each setting but it doesn’t seem to have an effect. Any ideas would be appreciated.
using System.Collections;using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5;
public float rotationSpeed = 450;
public Rigidbody rb;
private Camera cam;
Vector3 movement;
void Start()
{
cam = Camera.main;
}
private void FixedUpdate()
{
Movement();
faceMouse();
}
void Movement()
{
movement.x = Input.GetAxisRaw("Horizontal");
movement.z = Input.GetAxisRaw("Vertical");
rb.MovePosition(transform.position + movement * moveSpeed * Time.fixedDeltaTime);
}
void faceMouse()
{
Vector3 mousePos = Input.mousePosition;
mousePos = cam.ScreenToWorldPoint(new Vector3(mousePos.x, mousePos.y, cam.transform.position.y - transform.position.y));
rb.rotation = Quaternion.LookRotation(mousePos - transform.position);
}
}