My movement is not smooth
Hi, im made fps controller, but my movement is not smooth i tried * Time.deltaTime but it is doesnt help, also i tried to move.Normalize() it's helped my movespeed valoue doesn't matter using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMove : MonoBehaviour { public Rigidbody rb; public Transform _camera; public float moveSpeed = 6f; public float jumpForce = 10f; public LayerMask Ground; bool isGrounded; void Start() { } void Update() { //grounding isGrounded = Physics.CheckSphere(new Vector3(transform.position.x, transform.position.y - 1, transform.position.z), 0.4f, Ground); //facing direction Debug.DrawLine(_camera.position, transform.forward * 2.5f); //moving float x = Input.GetAxisRaw("Horizontal") * moveSpeed; float y = Input.GetAxisRaw("Vertical") * moveSpeed; //jumping if (Input.GetKeyDown(KeyCode.Space) && isGrounded) rb.velocity = new Vector3(rb.velocity.x, jumpForce, rb.velocity.z); //setting movement Vector3 move = transform.right * x + transform.forward * y; rb.velocity = new Vector3(move.x, rb.velocity.y, move.z); } }
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Player$$anonymous$$ove : $$anonymous$$onoBehaviour { public Rigidbody rb; public Transform _camera;
public float moveSpeed = 6f;
public float jumpForce = 10f;
public Layer$$anonymous$$ask Ground;
bool isGrounded;
void Start()
{
}
void Update()
{
//grounding
isGrounded = Physics.CheckSphere(new Vector3(transform.position.x, transform.position.y - 1, transform.position.z), 0.4f, Ground);
//facing direction
Debug.DrawLine(_camera.position, transform.forward * 2.5f);
//moving
float x = Input.GetAxisRaw("Horizontal") * moveSpeed;
float y = Input.GetAxisRaw("Vertical") * moveSpeed;
//jumping
if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
rb.velocity = new Vector3(rb.velocity.x, jumpForce, rb.velocity.z);
//setting movement
Vector3 move = transform.right * x + transform.forward * y;
rb.velocity = new Vector3(move.x, rb.velocity.y, move.z);
}
}