How can I jump in First Person Camera ? Activating RigidBody mess things up

Hi there !

I’m very new to unity and this is my first message.
I just started thinking I would love to make a simple game for myself and absolutely wanted to have it in first person. After following tutorials to get a nice first person movement and camera, I tried to implemente some code in order to jump but didn’t succeed… It seems that people activate ‘rigid body’ but when I do so, even if I turn on ‘freeze rotation x and z’ my capsule stills ‘get crazy’.

So I was thinking if there was an other way to make my character jump.
I’m sorry to come and just ask you guys, but I really tried for hours, following tutorials and stuff, and there is always something going wrong.
Thanks in advance.

Here are my two scripts if that can help :

Playermove

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class PlayerMove : MonoBehaviour

{

CharacterController charControl;

public float walkSpeed;

void Awake()

{

charControl = GetComponent();

}

void Update()

{

MovePlayer();

}

void MovePlayer()

{

float horiz = Input.GetAxis(“Horizontal”);

float vert = Input.GetAxis(“Vertical”);

Vector3 moveDirSide = transform.right * horiz * walkSpeed;

Vector3 moveDirForward = transform.forward * vert * walkSpeed;

charControl.SimpleMove(moveDirSide);

charControl.SimpleMove(moveDirForward);

}

}

Playerlook

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class PlayerLook : MonoBehaviour

{

public Transform playerBody;

public float mouseSensitivity;

float xAxisClamp = 0.0f;

void Awake()

{

Cursor.lockState = CursorLockMode.Locked;

}

void Update()

{

RotateCamera();

}

void RotateCamera()

{

float mouseX = Input.GetAxis(“Mouse X”);

float mouseY = Input.GetAxis(“Mouse Y”);

float rotAmountX = mouseX * mouseSensitivity;

float rotAmountY = mouseY * mouseSensitivity;

xAxisClamp -= rotAmountY;

Vector3 targetRotCam = transform.rotation.eulerAngles;

Vector3 targetRotBody = playerBody.rotation.eulerAngles;

targetRotCam.x -= rotAmountY;

targetRotCam.z = 0;

targetRotBody.y += rotAmountX;

if(xAxisClamp > 90)

{

xAxisClamp = 90;

targetRotCam.x = 90;

}

else if(xAxisClamp < - 90)

{

xAxisClamp = -90;

targetRotCam.x = 270;

}

transform.rotation = Quaternion.Euler(targetRotCam);

playerBody.rotation = Quaternion.Euler(targetRotBody);

}

}

No need to reply actually, just found a way using Character controller features !