I’ve been testing my game out and it started getting very laggy, I checked the unity profiler and it states that the Third Person Controller is very intensive, I need the TPC because without it their is no game, someone please help me out here. Heres the code if you need to look at it:
void Update()
{
float horizontal = joystick.Horizontal;
float vertical = joystick.Vertical;
Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;
killCounter.GetComponent<Text>().text = kill.ToString();
if (direction.magnitude >= 1f)
{
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);
animator.SetFloat("MovementSpeed", 1);
}
if(direction.magnitude <= 0f)
{
animator.SetFloat("MovementSpeed", 0);
dustTrail.Play();
FindObjectOfType<Audio>().Walk();
}
if(kill >= desiredKills)
{
light.color = (Color.cyan);
skull.SetTrigger("Extinguished");
}
}