Ejemplo n.º 1
0
    private void OnMove()
    {
        if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            moveSpeed = fastSpeed;
        }

        if (Input.GetKeyUp(KeyCode.LeftShift))
        {
            moveSpeed = normalSpeed;
        }

        OnVertical();
        OnHorizontal();

        yVar += gravity * Time.deltaTime;

        if (controller.isGrounded && movement.y < 0)
        {
            yVar      = -1f;
            jumpCount = 0;
        }

        if (Input.GetKeyDown(KeyCode.Space) && jumpCount < playerJumpCount.value)
        {
            yVar = jumpForce;
            jumpCount++;
        }

        movement = transform.TransformDirection(movement);
        controller.Move((movement) * Time.deltaTime);
    }
Ejemplo n.º 2
0
 private void Start()
 {
     moveSpeed  = normalSpeed;
     controller = GetComponent <CharacterController>();
     StartCoroutine(Move());
     transform.position = currentSpawnpoint.value;
 }
Ejemplo n.º 3
0
 private void Start()
 {
     currentSpeed = normalSpeed;
     controller   = GetComponent <CharacterController>();
     StartCoroutine(Move());
     wfs = new WaitForSeconds(waitTime);
     transform.position = currentSpawnpoint.value;
 }
Ejemplo n.º 4
0
    private IEnumerator Move()
    {
        canMove = true;
        while (canMove)
        {
            yield return(wffu);

            yVar += gravity * Time.deltaTime;
            var vInput = Input.GetAxis("Vertical") * currentSpeed.value * Time.deltaTime;
            var hInput = Input.GetAxis("Horizontal") * currentSpeed.value * Time.deltaTime;
            if (controller.isGrounded && movement.y < 0)
            {
                yVar      = -1;
                jumpCount = 0;
            }

            if (Input.GetButtonDown("Jump") && jumpCount < playerJumpMax.value)
            {
                yVar = jumpForce.value;
                jumpCount++;
            }


            if (Input.GetButtonDown("Fire3"))
            {
                currentSpeed = fastSpeed;
            }
            else if (Input.GetButtonUp("Fire3"))
            {
                currentSpeed = normalSpeed;
            }

            lookDirection.Set(hInput, 0, vInput);
            if (hInput > 0.05f || hInput < -0.05f || vInput > 0.05f || vInput < -0.05f)
            {
                finalDirection.Set(lookDirection.x, 0, lookDirection.z);
            }

            if (lookDirection != Vector3.zero)
            {
                transform.rotation = Quaternion.LookRotation(finalDirection);
            }

            movement.Set(hInput, yVar, vInput);
            controller.Move(movement);
        }
    }
Ejemplo n.º 5
0
    private IEnumerator Move()
    {
        canMove = true;
        while (canMove)
        {
            yield return(wffu);

            if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                moveSpeed = fastSpeed;
            }

            if (Input.GetKeyUp(KeyCode.LeftShift))
            {
                moveSpeed = normalSpeed;
            }
            var vInput = Input.GetAxis("Vertical") * moveSpeed.value;
            var hInput = Input.GetAxis("Horizontal") * moveSpeed.value;
            movement.Set(vInput, yVar, hInput);
            //var hInput = Input.GetAxis("Horizontal")*moveSpeed.value;
            //transform.Rotate(0,hInput,0);

            yVar += gravity * Time.deltaTime;

            if (controller.isGrounded && movement.y < 0)
            {
                yVar      = -1f;
                jumpCount = 0;
            }

            if (Input.GetButtonDown("Jump") && jumpCount < playerJumpCount.value)
            {
                yVar = jumpForce;
                jumpCount++;
            }

            movement = transform.TransformDirection(movement);
            controller.Move((movement) * Time.deltaTime);
        }
    }
Ejemplo n.º 6
0
 public void UpdateImageComponent(FloatDataScript dataObj)
 {
     imageComponent.fillAmount = dataObj.value;
 }
Ejemplo n.º 7
0
 private void Start()
 {
     moveSpeed  = normalSpeed;
     controller = GetComponent <CharacterController>();
     StartCoroutine(Move());
 }
Ejemplo n.º 8
0
    public void UpdateImage(FloatDataScript data)

    {
        img.fillAmount = data.value;
    }