#Vectors Help
1 messages · Page 1 of 1 (latest)
Vector arrowDirection = player.getLocation().getDirection();
Entity arrow = player.getWorld().spawn(player.getEyeLocation().add(arrowDirection), Arrow.class);
Entity arrow2 = player.getWorld().spawn(player.getEyeLocation().add(arrowDirection).add(1,0,0), Arrow.class);
Entity arrow3 = player.getWorld().spawn(player.getEyeLocation().add(arrowDirection).add(-1,0,0), Arrow.class);```
^ this part needs fixing ^
mmm wouldnt you want to use the player's Y and Z? - me goes to check add. for vectors
what is not working right now?
it works good but only when im facing the right side of the world in game
on certain sides it just shoots 3 arrows in one spot (not spreading them)
doesnt getEyeLocation only return the level of the eyes and not the direction?
im using eyelocation to get the direction the player is looking at, then adding one block forward so the arrows dont spawn in the players head and hurt it
Another solution would be to use
Entity arrow2 = player.getWorld().spawn(player.getEyeLocation().add(arrowDirection).add(0.5,0.5,0.5), Arrow.class);
Entity arrow3 = player.getWorld().spawn(player.getEyeLocation().add(arrowDirection).add(-0.5,-0.5,-0.5), Arrow.class);
instead
Actually if you shoot diagonally that won't help either
but you are not using the Location with yaw and pitch ...
now that should help
why would you want to?
the other doesnt return direction
The pitch/yaw is inherited from the player's pitch/yaw
yaw and pitch are weird sometimes and they cause performance issues so i just avoid using them
Oh, the player would damage itself there
also without pitch wouldnt the two extra arrows go flat instead of up/down ?
Either you slightly nudge the pitch/yaw or you change your 1 block offset to be based around the pitch yaw, however at that point you still get the sin/cos calls
pitch is interhited from the player
^ i want the arrow
i see it now, its a different one for head height.
wondering though can you not use the bow event and use getProjectile to duplicate the arrows?
double x = arrowLocation.getX();
Entity arrow2 = player.getWorld().spawn(player.getEyeLocation().add(arrowDirection).add(x +1,0,0), Arrow.class);
Entity arrow3 = player.getWorld().spawn(player.getEyeLocation().add(arrowDirection).add(x -1,0,0), Arrow.class);```
maybe this would do?
ill try it ig
no
Playing with thing, i think you might be looking for:
p.getWorld().spawnArrow(arrowOrigin, (arrowOrigin.subtract(arrowTarget)).toVector(), arrowForce, arrowSpread);
That should allow each arrow to hit the target, or at least close to it