Need help making particle wings.

Discussion in 'Plugin Development' started by Shadowdragon8969, Oct 12, 2016.

Thread Status:
Not open for further replies.
  1. I've been working on a hub plugin and I want to add particles. I thought the wings made out of particles on hypixel were pretty cool, but I'm not sure how to do this, but I'm guessing it requires parametric equations. I'm only in 9th grade so I'm no good with cos and sin but I am pretty familiar with the Bukkit API and I've been using packets to display particles due to darkblade's particle library not working with my version of Bukkit. Thank you!
     
  2. Offline

    I Al Istannen

    @Shadowdragon8969
    Could you post a gif (or picture, if they don't move) of how they look?
     
  3. Offline

    Zombie_Striker

    @Shadowdragon8969
    Even if you don't know the equations how to do certain things, you can always use google to find them. In some cases, you don't even need equations. You can just build a model of how the particles are supposed to be placed and just use that model for the wings.

    Without being able to see the wings you are looking for, we won't be able to help you.
     
  4. Attached Files:

  5. Offline

    mythbusterma

    @Zombie_Striker @Shadowdragon8969

    This one is a little bit more difficult because you want them to appear at an offset behind the player. First, you're going to have to figure out a vector that points directly behind the player, something like this:

    Code:
    Vector temp = player#getLocation().getDirection().multiply(-0.5);
    temp.setY(0);
    
    Creates a vector that points directly behind where the player is looking, and won't be affected by the player looking up and down. You can use this as an offset from the player's position to center your wings around. This creates a vertical axis that you can draw the wings on, as we only define an X and Z offset.

    Now you need to determine the angle at which to draw the wings, relative the positive X axis (looking down at this, it would look like it's spinning).

    To do this, you can cheat a little bit since we only need one angle, and use the built in Bukkit method.

    Code:
    Vector positiveX = new Vector(1, 0, 0);
    // ...
    // temp is our vector
    float angle = temp.angle(positiveX);
    
    This gives you an angle in radians that you have to rotate your particles by.

    According to Wikipedia, your positions will be rotated like this:

    [​IMG]

    In this case, theta being "angle." Since in Minecraft, the y axis is the vertical axis and we're looking top down, swap y out for z.

    I would have all of your particles be at offsets from the center of the player's back, then figure out what their rotated offset is using this angle, then add the player's position to the value, then add the vector between the player and the axis I mentioned.
     
  6. Offline

    Whoneedspacee

    On top of learning all that math, you should probably pick a good particle type that doesn't linger or leave annoying shit.
     
  7. @mythbusterma
    Can you explain in a little more detail on how to rotate and find offsets
    I'm very confused right now, I don't know what I'm doing
     
    Last edited: Oct 14, 2016
  8. Offline

    mythbusterma

    @Shadowdragon8969

    I'm not sure how much more detailed I can be. I already told you how to find the offset from the player, and the offset due to rotation. It's helpful to image the rotation as a "translation," in the same way that you would translate between languages.

    Apple -> manzana

    input position -> output position

    In this case, Apple maps to manzana, and the function that maps them is English to Spanish. In a similar vein, input position is mapped to output position, and the function that maps them is:

    [​IMG]

    Where x' and y' define the output position (again, remember to substitute z for y in this).

    I'm not sure what you're unclear on, but if you're more specific I can help you better.
     
  9. @mythbusterma
    I don't understand how to declare the x and y variables and add them to the location. An example would help, I'm just not sure what I need to use sin and cos on and then afterwards what do I do with those variables.
     
  10. Offline

    Zombie_Striker

    Declaring variables is basic Java. Declare those doubles (use doubles instead of ints if you want the directions to be more accurate) and set them equal to the equation Mythbusterma provided.
    That is not happening. We are against spoonfeeding code here. If you cannot understand what we are telling you, either ask for better explanation or try googling the words/topics discussed.

    The reason why we don't spoonfeed is because A) we do not want to be writing your plugin for you B) It makes you dependent on us to write code for you, and C) It does not teach you how to troubleshoot or figure out your own problems (Going back to point B).

    As explained by Mythbusterma's first post, what you are doing is figuring out the angle you need to spawn the particles.

    Using the angle from above, use that as the offset for the X and Z location. As you increase the X by the X variable, increase the Z by the Z variable.
     
  11. Offline

    mythbusterma

    @Shadowdragon8969

    So to declare x and y:

    Code:
    double x = //...
    double y = //...
    
    I wouldn't do this with a Location, but rather you should be using Vectors. To add these values to a Vector:

    Code:
    Vector copy = vector.setX(copy.getX() + x);
    copy = copy.setY(copy.getY() + y);
    
    Keep in mind Vectors are "value objects" and copy themselves any time you try to change them.
     
Thread Status:
Not open for further replies.

Share This Page