charticter

Posted by Paidboom - 5 months ago

charticter : unity 3d how to make charticter controler unity 3d character controller

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    CharacterController characterController;

    public float speed = 6.0f;
    public float jumpSpeed = 8.0f;
    public float gravity = 20.0f;

    private Vector3 moveDirection = Vector3.zero;

    void Start()
    {
        characterController = GetComponent<CharacterController>();
    }

    void Update()
    {
        if (characterController.isGrounded)
        {

            moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0.0f, Input.GetAxis("Vertical"));
            moveDirection *= speed;

            if (Input.GetButton("Jump"))
            {
                moveDirection.y = jumpSpeed;
            }
        }


        moveDirection.y -= gravity * Time.deltaTime;
        characterController.Move(moveDirection * Time.deltaTime);
    }
}   

my charticter - Pixilart, free online pixel drawing tool - This drawing tool allows you to make pixel art, game sprites and animated GIFs online for free. Read Feelings Reveled and a new charticter from the story Hidden behind.