// This script strikes the character controller ahead
// and sideways based mostly on the arrow keys.
// It additionally jumps when urgent house.
// Make positive to connect a personality controller to the identical recreation object.
// It is advisable that you just make just one name to Move or EasyMove per body.
public class ExampleClass : MonoBehaviour
public float pace = 6.0f;
public float jumpSpeed = 8.0f;
public float gravity = 20.0f;
personal Vector3 moveDirection = Vector3.zero;
characterController = GetComponent<CharacterController>();
// We are grounded, so recalculate
// transfer course straight from axes
moveDirection = new Vector3(Input.GetAxis(“Horizontal”), 0.0f, Input.GetAxis(“Vertical”));
moveDirection *= pace;
moveDirection.y = jumpSpeed;
// Apply gravity. Gravity is multiplied by deltaTime twice (as soon as right here, and as soon as under
// when the moveDirection is multiplied by deltaTime). This is as a result of gravity needs to be utilized
// as an acceleration (ms^-2)
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
characterController.Move(moveDirection * Time.deltaTime);
C# solutions associated to “movement script c#”
C# queries associated to “movement script c#”
Browse C# Answers by Framework