title: How to add "jump" in C# script in Unity3d using Character Controller?
body: <p>I made it possible for the character to walk in 8 directions, but I don’t know how to add a “jump” to make everything work...</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class PlayerMovement : MonoBehaviour {
  
      public CharacterController controller;
      public float speed;
      float turnSmoothVelocity;
      public float turnSmoothTime;
  
      void Update() {
          float horizontal = Input.GetAxisRaw("Horizontal");
          float vertical = Input.GetAxisRaw("Vertical");
  
          Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;
  
          if (direction.magnitude &gt;= 0.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);
          }
      }
  }
  </code></pre>