I have been attempting to create a helix that takes into account the players's yaw and pitch in order to spawn it where the player is facing. However it just makes a straight line and I am not sure why (not where the player is facing). I have been searching everywhere for the solution and have not been successful. Current code: https://pastebin.com/Sfd0T6D5
The first thing I would think of is that x, y, z might be equal to zero. Though this contradicts what I would think by looking at the code, could you attempt a debug message that prints those numbers? If it prints something other then zero, could you print the location's x (location.getX()) to confirm that the location's x is correct.
On it, @PhantomUnicorns I printed the eyeX, Y, and Z: 30.06 00:13:40 [Server] INFO -926.3182885087442 30.06 00:13:40 [Server] INFO 108.14623313020196 30.06 00:13:40 [Server] INFO 2345.3513754923597 https://pastebin.com/rPvZaCbr Printed the coords the particles spawn at I had a friend help make one and it ALMOST works, just not in all directions: https://hastebin.com/anomililev.java
Right away I can say: bravo, you are working on a tough topic. This kind of geometry isn't that easy anymore. Further I can say idk what exaclty you friend tried to code but I think it a wrong approach xD sorry My concept (which worked for me) was to first create a the current part of the helix as a vector facing yaw: 0 pitch: 0 and afterwards rotate it around the player's yaw and pitch. The code I used looked like this: Firstly, there was a mistake about the yaw calculation. I used these values: Code: double yaw = Math.toRadians(loc.getYaw() + 90); double pitch = -Math.toRadians(loc.getPitch()); So the vector for a default helix without rotation would look like this: Code: angle += 181 Vector vec = new Vector( angle / 1800D, Math.sin(angle) * radius, Math.cos(angle) * radius); it would just be a helix along the x-axis. To get it facing into the direction the player was looking I used this piece of code: Code: double x, y, z; //pitch rotation x = vec.getX(); y = vec.getY(); vec.setX(x * Math.cos(pitch) - y * Math.sin(pitch)); vec.setY(x * Math.sin(pitch) + y * Math.cos(pitch)); //yaw rotation x = vec.getX(); z = vec.getZ(); vec.setX(x * Math.cos(yaw) - z * Math.sin(yaw)); vec.setZ(x * Math.sin(yaw) + z * Math.cos(yaw)); You don't really have to understand it... Last thing would be to apply the vector to a copy of the location and spawn the particle there: Code: world.spawnParticle(particle, loc.clone().add(vec), 1); Furthermore I think you spawnHelix() methode dosn't need to be static at all, and I think you should rather run your BukkitRunnable as a timer than running it asynchronously and using Thread.sleep()
You calculate your x twice? Is that not pointless...? First of all, thank you. I will try to use this to make it work. Second, I originally made it non static and with a runnable, a friend helped and that is how it ended up. Edit: THANK YOU SO MUCH IT WORKS