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
On this page of the site you can watch the video online How To Code A Simple Walking Script With C# In Unity with a duration of hours minute second in good quality, which was uploaded by the user ProgrammersProdigy 21 January 2023, share the link with friends and acquaintances, this video has already been watched 301 times on youtube and it was liked by 8 viewers. Enjoy your viewing!