Beispiel #1
0
    public void Shoot()
    {
        // set firepoint direction
        Vector3 firepointDir = new Vector3(firePoint.position.x + isoRenderer.diraxis.x, firePoint.position.y + isoRenderer.diraxis.y, firePoint.position.z);

        // set angle bullet
        angle = MathfCalculate.DegreeFromVector2(isoRenderer.diraxis);
        var firepointRot = Quaternion.AngleAxis(angle, Vector3.forward + new Vector3(0.1f, 0, 0.1f));
        // instantiate bullet
        var firedBullet = Instantiate(bulletPrefab, firepointDir, firepointRot);
    }
Beispiel #2
0
    void Move()
    {
        Vector2 currentPos      = rbody.position;
        float   horizontalInput = joystick.Horizontal;
        float   verticalInput   = joystick.Vertical;
        Vector2 inputVector     = new Vector2(horizontalInput, verticalInput);

        inputVector = Vector2.ClampMagnitude(inputVector, 1);
        Vector2 movement = inputVector * movementSpeed;
        Vector2 newPos   = currentPos + movement * Time.fixedDeltaTime;

        isoRenderer.SetDirection(movement);
        rbody.MovePosition(newPos);

        MathfCalculate.DegreeFromVector2(inputVector);
        //Debug.Log(inputVector +" Degree : "+ MathfCalculate.DegreeFromVector2(inputVector).ToString());
        diraxis = inputVector;
        angle   = MathfCalculate.DegreeFromVector2(inputVector);
    }