# unity – Does anyone know how to make a good 3rd person rigid body controller?

I’m trying to create my first ever game in Unity, and even though it may be hard I’m trying to create a 3d platformer inspired by games like Crash Bandicoot, as I was researching for a way to control character I found that there are two ways, the character controller and rigid body, and while researching I discovered that the one that would most suit my game would be a rigid body controller, but I couldn’t find anywhere a good 3rd person rigid body controller, so what I am using now is a very bad character controller script that tries to imitate the rigid body controller in aspects of gravity, jumping and sliding, but it’s not very consistent, I was wondering if anyone knew or could help me create a rigid body controller for my game.

for anyone who wants to know the code I’m using it is right below:

ps: as I said this is my first game so I am very lost when it comes to coding this is also a reason why I need some help.

``````using UnityEngine;

public class PlayerMovement : MonoBehaviour
{

public CharacterController controller;

public float speed = 10f;

//turnning smoothness

public float turnSmoothTime = 0.1f;
float turnSmoothVelocity;

//jump controls

public float jumpHeight = 3f;
public float gravity = -29.43f;
Vector3 velocity;
bool isGrounded;

//gravity check
public Transform groundCheck;
public float groundDistance = 0.4f;

// Update is called once per frame
void Update()
{
isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

if(isGrounded && velocity.y < 0)
{
velocity.y = -1f;
}

//player movement on both axis

float horizontal = Input.GetAxisRaw("Horizontal");
float vertical = Input.GetAxisRaw("Vertical");

Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;

velocity.y += gravity * Time.deltaTime;
controller.Move(velocity * Time.deltaTime);

if (Input.GetKeyDown("space") && isGrounded)
{
velocity.y += Mathf.Sqrt(jumpHeight * -2f * gravity);
}

if (direction.magnitude >= 0.1f)
{
//player turning depending on where moving

float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime);
transform.rotation = Quaternion.Euler(0f, angle, 0f);

controller.Move(direction * speed * Time.deltaTime);

}

}

}
``````