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
Nesta página do site você pode assistir ao vídeo on-line How To Code A Simple Walking Script With C# In Unity duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário ProgrammersProdigy 21 Janeiro 2023, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 301 vezes e gostou 8 espectadores. Boa visualização!