using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
[RequireComponent(typeof(CharacterController))]
public class PlayerController : MonoBehaviour
{
public float walkSpeed = 5f;
public float runSpeed = 10f;
public float jumpHeight = 1.9f;
public float gravityScale = -20f;
Vector3 moveInput = Vector3.zero;
CharacterController characterController;
private void Awake()
{
characterController = GetComponent();
}
private void Update()
{
Move();
}
private void Move()
{
if (characterController.isGrounded)
{
moveInput = new Vector3(Input.GetAxis(“Horizontal”), 0f, Input.GetAxis(“Vertical”));
moveInput = Vector3.ClampMagnitude(moveInput, 1f);
if (Input.GetButtonshift(“Sprint”))
Debug.Log(“Sprint”);
{
moveInput = transform.TransformDirection(moveInput) * runSpeed;
}
else
{
moveInput = transform.TransformDirection(moveInput) * walkSpeed;
}
if (Input.GetButtonDown(“Jump”))
Debug.Log(“Jump”);
{
moveInput.y = Mathf.Sqrt(jumpHeight * -2f * gravityScale);
}
}
moveInput.y += gravityScale * Time.deltaTime;
characterController.Move(moveInput * Time.deltaTime);
}
}
posdata: me salieron 999+ por las teclas que me pone CS1513 xd