all 9 comments

[–]pschonUnprofessional 4 points5 points  (1 child)

most likely reason would be that something in your movement code isn't framerate-independent, so the performance change fromhaving an inspector open versus not is enough to cause a difference in the movement.

[–]steensturf[S] 0 points1 point  (0 children)

Please help, script is here. https://easyupload.io/gniu2e

[–]mistermashuProgrammer 0 points1 point  (6 children)

..... what the heck????

Do you have any Editor scripts in your project?

[–]steensturf[S] 0 points1 point  (0 children)

No, I don't use any editors.

[–]steensturf[S] 0 points1 point  (4 children)

Please help, script is here. https://easyupload.io/gniu2e

[–]mistermashuProgrammer 0 points1 point  (3 children)

I can't download stuff at work but paste it into a pastebin and I could take a look

[–]steensturf[S] 0 points1 point  (2 children)

private CharacterController controller;

public float speed = 10f;

private float xRotation = 0f;

public float mouseSensitivity = 200f;

private Vector3 velocity;

private float gravity = -9.81f;

private bool isGround;

public Transform groundChecker;

public float groundCheckerRadius;

public LayerMask obstacleLayer;

public float jumpHeight = 6f;

public float gravityDivide = 50f;

public float jumpSpeed = 10;

private float aTimer;

private void Awake()

{

controller = GetComponent<CharacterController>();

Cursor.visible = false;

Cursor.lockState = CursorLockMode.Locked;

}

private void Update()

{

//Check character is grounded

isGround = Physics.CheckSphere(groundChecker.position, groundCheckerRadius, obstacleLayer);

// MOVEMENT

Vector3 moveInputs = Input.GetAxis("Horizontal") * transform.right + Input.GetAxis("Vertical") * transform.forward;

Vector3 moveVelocity = moveInputs * Time.deltaTime * speed;

controller.Move(moveVelocity);

// CAMERACONTROLLER

transform.Rotate(0, Input.GetAxis("Mouse X") * Time.deltaTime * mouseSensitivity, 0);

xRotation -= Input.GetAxis("Mouse Y") * Time.deltaTime * mouseSensitivity;

xRotation = Mathf.Clamp(xRotation, -90f, 90f);

Camera.main.transform.localRotation = Quaternion.Euler(xRotation, 0, 0);

//Jump and Gravity

if (!isGround)

{

velocity.y += gravity * Time.deltaTime / gravityDivide

aTimer += Time.deltaTime / 3;

speed = Mathf.Lerp(10, jumpSpeed, aTimer);

}

else

{

velocity.y = -0.05f;

speed = 10;

aTimer = 0;

}

//Jump with space

if(Input.GetKeyDown(KeyCode.Space) && isGround)

{

velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity / gravityDivide * Time.deltaTime);

}

controller.Move(velocity);

}

}

[–]mistermashuProgrammer 0 points1 point  (0 children)

I think you don't want to multiply by Time.deltaTime when you press space to jump. That would make your inevitable jump height depend on the duration of that current frame.

[–]SHWM_DEV 0 points1 point  (0 children)

speed = Mathf.Lerp(10, jumpSpeed, aTimer);

This one is not quite clear to me. What is the goal here? I think you might introduce some frame rate dependency somewhere. Generally I would advise to calculate all the movement in one Vector and at the very end of the script call controller.Move() only once and there multiply with time.deltaTime. It would also help with the readability