Particle Helix by Vector

Discussion in 'Plugin Development' started by Mysticate, Nov 3, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Mysticate

    After seeing the incredible particle resource by Skionz, I can't help wondering if there is any way to make the same helix, but instead of going straight up, have it going in the direction a player is facing? I'm terrible with that kind of thing (trig) so any help would be appreciated.
     
    Skionz likes this.
  2. Offline

    ChipDev

    I don't get what you want, it will loop in the player facing direction?
     
  3. Offline

    Barinade

    A spiral coiled around the player's line of sight
     
  4. Offline

    mythbusterma

    Mysticate

    Honestly, you could just swap the x and y values and that would get you started, although it would be fixed to one axis, not lining up with the player's line of sight.
     
  5. Offline

    Skionz

    Mysticate Yea this would be complicated but pretty badass
     
  6. Offline

    Mysticate

    Skionz Barinade mythbusterma Yeah... I was thinking about using it when a player shoots a fireball so it circles around it as it goes through the air.

    EDIT: ChipDev, I want to know how to make the helix/spiral point in the direction that the player is looking at... Any ideas?
     
  7. Offline

    Barinade

    It's been a long time since I've done anything with Bukkit but I'm gonna give this a shot.
     
    Skionz likes this.
  8. Offline

    ChipDev

    That seems hard... You can use LCastr0 's EffectLib (Made by Slikey) using the cone effect!
     
  9. Offline

    LCastr0

    Rotate the vector in the way the player is facing (I currently do it using VectorUtils and MathUtils, in EffectLib, which you can find here: http://forums.bukkit.org/threads/ef...-the-nice-way-text-image-in-particles.259879/ )
    Code:java
    1.  
    2. VectorUtils.rotateAroundAxisX(<vector>, (<player/location><.getLocation(), if its a player>.getPitch() + 90) * MathUtils.degreesToRadians);
    3. VectorUtils.rotateAroundAxisY(<vector>, -<player/location><.getLocation()>.getYaw() * MathUtils.degreesToRadians);
    4.  
     
    ChipDev and bennie3211 like this.
  10. Offline

    Mysticate

    LCastr0 But how do I use that?
     
  11. Offline

    LCastr0

    Just put it in your code, the methods will do everything for you.
    After you place this code, spawn the helix at the location you want and .add(<vector>);
     
  12. Offline

    Mysticate

    LCastr0 Is there any way to do it without EffectLib?
     
  13. Offline

    LCastr0

    You could look the source of the VectorUtils and MathUtils and just get the parts of the code that you need (rotateroundAxisX and Y, degreesToRadians)
     
  14. Offline

    Mysticate

    LCastr0 But how do I use that in relation to Skionz 's code?
    Code:
    public void createHelix(Player player) {
        Location loc = player.getLocation();
        int radius = 2;
        for(double y = 0; y <= 50; y+=0.05) {
            double x = radius * Math.cos(y);
            double z = radius * Math.sin(y);
            PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles("fireworksSpark", (float) (loc.getX() + x), (float) (loc.getY() + y), (float) (loc.getZ() + z), 0, 0, 0, 0, 1);
            for(Player online : Bukkit.getOnlinePlayers()) {
                ((CraftPlayer)online).getHandle().playerConnection.sendPacket(packet);
            }
        }
    }
     
  15. Offline

    LCastr0

    Code:
    Location loc = player.getLocation();
    Vector v = new Vector(0, 0, 0);
    <rotate the vectors like I explained above>
    loc.add(v);
    <then just use the rest of your code>
    
     
  16. Offline

    Mysticate

    LCastr0 but it doesn't do anything other than circle up...
    Code:
    public void createHelix(Player player) {
            Location loc = player.getLocation();
            Vector v = new Vector(0, 0, 0);
            rotateAroundAxisX(v, (player.getLocation().getPitch() + 90) * degreesToRadians);
            rotateAroundAxisY(v, (player.getLocation().getYaw()) * degreesToRadians);
            loc.add(v);
            int radius = 2;
            for(double y = 0; y <= 50; y+=0.05) {
                double x = radius * Math.cos(y);
                double z = radius * Math.sin(y);
                PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles("fireworksSpark", (float) (loc.getX() + x), (float) (loc.getY() + y), (float) (loc.getZ() + z), 0, 0, 0, 0, 1);
                for(Player online : Bukkit.getOnlinePlayers()) {
                    ((CraftPlayer)online).getHandle().playerConnection.sendPacket(packet);
                }
            }
        }
     
  17. Offline

    Skionz

    Mysticate Thats cause your incrementing y
     
  18. Offline

    mythbusterma

    Mysticate

    Did you completely ignore my above post?
     
  19. Offline

    ChipDev

    Of course, LCastr0 saves the day :D
     
  20. Offline

    LCastr0

    You have to increment either X or Z, not Y, as Skionz said.
     
    Regablith and bennie3211 like this.
  21. Offline

    Slikey

    The EffectLib has the Vortex effect, doing exactly what you want.
     
    Regablith likes this.
  22. Offline

    LCastr0

     
  23. Offline

    ChipDev

    No, I think he wants a cone effect not incrementing its radius.
     
Thread Status:
Not open for further replies.

Share This Page