Thanks For Watching
Some Parts Will Be Missing Angled Brackets Because YouTube Doesn't Allow It
The First Code Is
--------------------------------------------------------------
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
public float jumpForce = 5f;
private CharacterController characterController;
void Start()
{
characterController = GetComponent CharacterController ();
}
void Update()
{
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(horizontal, 0f, vertical);
characterController.Move(movement * moveSpeed * Time.deltaTime);
if (Input.GetButtonDown("Jump") && characterController.isGrounded)
{
characterController.Move(Vector3.up * jumpForce);
}
}
}
---------------------------------------------------------------
The Second Code Is
----------------------------------------------------------------
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
public float jumpForce = 5f;
Rigidbody rb;
void Start()
{
rb = GetComponent Rigidbody ();
}
void Update()
{
float moveX = Input.GetAxis("Horizontal");
float moveZ = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveX, 0f, moveZ);
rb.AddForce(movement * moveSpeed);
if (Input.GetKeyDown(KeyCode.Space))
{
rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
}
}
}
----------------------------------------------------------------------
#tutorial #coding #howto
En esta página del sitio puede ver el video en línea How To Code A Simple Walking Script With C# In Unity de Duración hora minuto segunda en buena calidad , que subió el usuario ProgrammersProdigy 21 enero 2023, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 301 veces y le gustó 8 a los espectadores. Disfruta viendo!