void MoveToPosition(Vector3 position, float speedMult, float magnitude)
    {
        float speed = movement_Speed * speed_Move_Multiplier * 2 * 5 * speedMult;

        Vector3 direction = position - transform.position;

        Quaternion newRotation = transform.rotation;

        direction.y = 0f;

        if (direction.magnitude > 0.1f)
        {
            motor.Move(direction.normalized * speed);

            newRotation = Quaternion.LookRotation(direction);

            transform.rotation = Quaternion.Slerp(transform.rotation, newRotation,
                                                  turnSpeed * Time.deltaTime);
        }
        else
        {
            motor.Stop();
        }

        AnimationMove(magnitude * 0.1f);

        CheckIfAttackEnded();
    }
Exemple #2
0
    private void OnUpdate(float deltaTime)
    {
        _selector.CheckSelection();

        _movementMotor.Move();

        LookAtAnchor();
    }
Exemple #3
0
    //Movement method
    private void Movement()
    {
        //Calculate the axis of movement
        float _horizontal = Input.GetAxis("Horizontal");
        float _vertical   = Input.GetAxis("Vertical");

        Vector3 _direction = transform.right * _horizontal + transform.forward * _vertical;

        //Move the player
        motor.Move(_direction, speed);

        //If is is grounded then can jump
        if (motor.isGrounded)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                motor.Jump(jumpForce);
            }
        }
    }