mmxfjktg

using UnityEngine;

public class BearController : MonoBehaviour
{
   public float speed = 6f;
   public float gravity = -9.81f;
   public float jumpHeight = 2f;

   private CharacterController controller;
   private Vector3 velocity;
   private bool isGrounded;

   void Start()
   {
       controller = GetComponent<CharacterController>();
   }

   void Update()
   {
       isGrounded = controller.isGrounded;

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

       float moveX = Input.GetAxis("Horizontal");
       float moveZ = Input.GetAxis("Vertical");

       Vector3 move = transform.right * moveX + transform.forward * moveZ;

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

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

       velocity.y += gravity * Time.deltaTime;

       controller.Move(velocity * Time.deltaTime);
   }
}using UnityEngine;

public class CameraFollow : MonoBehaviour
{
   public Transform target;
   public Vector3 offset;

   void LateUpdate()
   {
       transform.position = target.position + offset;
       transform.LookAt(target);
   }
}X: 0
Y: 5
Z: -7

0

Please sign in to leave a comment.