Solved How to create Angel Wings Particels

Discussion in 'Plugin Development' started by lgplay, Nov 16, 2019.

Thread Status:
Not open for further replies.
  1. Hi,

    I need help with creating an Angel Wing effect for my cosmetics Plugin. Can someone some help me creating one? I can create Particles, but I don't know how to shape the Wing.
     
  2. Offline

    robertlit

    What have you already tried? What is the problem?

    It shouldn't be hard just spawn particles with a little offset each time..
     
  3. I really don't know how to start with this,
    My main Problem is how to turn the wings in the right direction when they spawn
     
  4. Offline

    robertlit

    Spawn them based on the direction the player is looking
     
  5. I suggest first putting the coordinates into 3 arrays: 1 for the x, y and z coordinates while ignoring the rotation of the player (for now, assume the player is looking towards the negative z direction. I will help you with the mathematics of dealing with the rotation later, but first make the arrays.
    If you don't want too many particles, you can just hardcode the arrays.
     
    lgplay likes this.
  6. Thanks for the Answer I have got it now like this

    Code:
    int arr[][] = {
                    {0, 0, 0, 0, 1, 1, 1, 0, 0, 0},
                    { 0, 0, 0, 1, 1, 1, 1, 1, 0, 0 },
                    { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0 },
                    { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0 },
                    { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 },
                    { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 },
                    { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                    { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                    { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                    { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                    { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                    { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1 },
                    { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1 },
                    { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1 },
                    { 0, 0, 0, 0, 0, 1, 1, 1, 1, 0 },
                    { 0, 0, 0, 0, 0, 1, 1, 1, 1, 0 },
                    { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0 },
                    { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 },
                    { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 } };
    
    
    public void summon(Player p) {
            double x = p.getLocation().getX() - 2;
            double y = p.getLocation().getY() + 1;
            double z = p.getLocation().getZ() + 0.5;
    
            System.out.println(p.getLocation().getYaw());
    
            for (int i = 0; i < arr.length; i++) {
                for (int j = 0; j < arr[i].length; j++) {
                    if (arr[i][j] > 0) {
                        p.spawnParticle(Particle.DAMAGE_INDICATOR, x, y, z, 1, 0, 0, 0, 0, this.partileData);
                    } else {
                    }
                    x += 0.2;
                }
                x = p.getLocation().getX() - 2;
                y -= 0.1;
            }
        }
    Is it good like this it works. And I really would need help with the rotation pls I don't have a clue how to start with this
     
    Last edited: Nov 17, 2019
  7. Not exactly what I had in mind, but this should do, it just requires a few changes:
    Currently, you define x to be the playerX - 2, and then increase the value by 0.2 after every particle. I need you to instead define x to be -2 (and then increase the value by 0.2 after every particle). In the spawnParticle, you should then use playerX + x instead of just x. If you do that correctly, it should show the same cape as it does currently. (But your code will be in a more convenient 'shape' for handling the rotation.)

    Once you managed to do that with the x-coordinate, do the same with the y and z coordinates and verify again that you still see the exact same particle cape. (You shouldn't decrease y by 0.1 after every row and not change z.) Let me know once you managed to do this.
     
    lgplay likes this.
  8. Hi, sorry for not replying, I did this id now looks like this

    Code:
        public void summonLeft(Player p) {
            double x = -1.1;
            double y = 1;
            double z = 0.5;
    
            for (int i = 0; i < arr.length; i++) {
                for (int j = 0; j < arr[i].length; j++) {
                    if (arr[i][j] > 0) {
                        p.spawnParticle(Particle.DAMAGE_INDICATOR, p.getLocation().getX() + x, p.getLocation().getY() + y,
                                p.getLocation().getZ() + z, 0, 0, 0, 0, 0, null);
                    } else {
                    }
                    x += 0.1;
                }
                x = -1.1;
                y -= 0.05;
            }
        }
    
        public void summonRight(Player p) {
            double x = 0.1;
            double y = 1;
            double z = 0.5;
    
            for (int i = 0; i < arr.length; i++) {
                for (int j = 9; j >= 0; j--) {
                    if (arr[i][j] > 0) {
                        p.spawnParticle(Particle.DAMAGE_INDICATOR, p.getLocation().getX() + x, p.getLocation().getY() + y,
                                p.getLocation().getZ() + z, 0, 0, 0, 0, 0, null);
                    } else {
                    }
                    x += 0.1;
                }
                x = p.getLocation().getX() + 0.1;
                y -= 0.05;
            }
        }
    can you help me making the next step?
     
  9. @lgplay

    The current state of your code is much like what I had in mind, so now we can proceed easily.
    First, you need to obtain the yaw by using `double yaw = Math.toRadians(p.getLocation().getYaw());`.

    Currently, you are using `p.getLocation().getX() + x`. You should replace that with `p.getLocation().getX() + x * -Math.sin(yaw)` and you should replace `p.getLocation().getZ() + z` with `p.getLocation().getZ() + z * Math.cos(yaw)`.

    If I did the math correctly, that should either give the correct rotation or it should give the correct rotation, but with an 'offset' of a multiple of 90 degrees. If this doesn't work right away, try using something like `double yaw = Math.toRadians(p.getLocation().getYaw() + 90);` (and something similar with 180 and 270).
     
    lgplay likes this.
  10. @knokko
    Still need help pls , now it just turns from right to left and in the middle of the turn its just a stack of effects View attachment 32674 View attachment 32675 View attachment 32676

    Code:
    public void summonLeft(Player p) {
            double yaw = Math.toRadians(p.getLocation().getYaw() + 90);
            double x = -1.1;
            double y = 1;
            double z = 0.5;
    
            for (int i = 0; i < arr.length; i++) {
                for (int j = 0; j < arr[i].length; j++) {
                    if (arr[i][j] > 0) {
                        p.spawnParticle(Particle.DAMAGE_INDICATOR, p.getLocation().getX() + x * -Math.sin(yaw),
                                p.getLocation().getY() + y, p.getLocation().getZ() + z * Math.cos(yaw), 0, 0, 0, 0, 0,
                                null);
                    } else {
                    }
                    x += 0.1;
                }
                x = -1.1;
                y -= 0.05;
            }
        }
     
  11. @lgplay

    I indeed made a mistake because I confused this with something else. The correct way should be something like:
    particleX = p.getLocation().getX() + x * Math.cos(yaw) + z * -Math.sin(yaw)
    particleZ = p.getLocation().getZ() + x * Math.sin(yaw) + z * Math.cos(yaw)

    I might have made another mistake (annoying to reason about this), so let me know how this works out.
     
    lgplay likes this.
  12. Thanks, for helping me, you saved my day thank you so much. I will not bother you anymore.
     
Thread Status:
Not open for further replies.

Share This Page