Vectors and particles (a little big challenge)

Discussion in 'Plugin Development' started by 4thegame3, Oct 30, 2015.

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

    4thegame3

    Hello.
    I'm trying to make an helix around a vector with particles.
    But I can't figure out how i could do that.
    Is there someone that can help me on that? Have you got any brillant ideas?
     
  2. Offline

    oceantheskatr

  3. Offline

    4thegame3

    I saw it already. I need to implement it to a vector.
    The helix must follow a projectile and go in the same direction.
     
  4. Offline

    Zombie_Striker

    @4thegame3
    You know what would help? Some math.
    The Y in this case is the location which stays the same. It will rotate around the Y axis. replace the Y with the direction in which the projectile is moving.
     
  5. Offline

    4thegame3

    Works only if I shoot the projectile (fireball) up or down. Not horizontally.
     
  6. Offline

    Zombie_Striker

    @4thegame3
    I know, thats because the x is the cos and z is the sin. You have to change one of those two to a Y, that way it may look like (y = Math.cos(x)) or something like that.
     
  7. Offline

    4thegame3

    Uhm... yea i knew that but what about if the pich (or yaw i dont remember actually) is 45 degree? che helix will result a bit flat.
     
  8. Offline

    Zombie_Striker

    @4thegame3
    If its at 45 degrees, you would need some "extra math" to rotate the x/z values (add some to the x, remove some from the z) so that they "even out".
     
  9. Offline

    4thegame3

    Solved using EffectLib libraries, VectorUtils and MathUtils.
    Code:
                for (int i = 0; i < helixes; i++) {
                    double angle =step * radials + (2 * Math.PI * i / helixes);
                    Vector v = new Vector(Math.cos(angle) * radius, 0/* * grow */, Math.sin(angle) * radius);
                    VectorUtils.rotateAroundAxisX(v, (startLoc.getPitch() + 90) * MathUtils.degreesToRadians);
                    VectorUtils.rotateAroundAxisY(v, -startLoc.getYaw() * MathUtils.degreesToRadians);
                    location.add(v);
                    display(effect, location,Color.GRAY);
                    location.subtract(v);
                }
     
Thread Status:
Not open for further replies.

Share This Page