#Volleyball math
1 messages · Page 1 of 1 (latest)
Alright so I believe the elements for this are only:
DirectionFactor
YFactor
This should control the direction of the ball and the pitch value, right? Then I can change the speed of the entity
this.owner.getLogger().log(Level.INFO, "----------------------------------------");
this.owner.getLogger().log(Level.INFO, " Player hitting ball");
this.ballSpeedRegulator.resetMaxFallSpeed();
getBall().setGravity(true);
double directionFactor = 0.0D;
double yFactor = 0.0D;
if (hitter.isSprinting()) {
directionFactor += 0.55D;
this.owner.getLogger().log(Level.INFO, " Player is sprinting (+ 0.220)");
}
if (!hitter.isOnGround()) {
directionFactor += 0.55D;
this.owner.getLogger().log(Level.INFO, " Player is not on the ground (+ 0.55)");
}
if (hitter.getLocation().getPitch() < -85.0F) {
yFactor += 3.0D;
directionFactor = 0.7D;
this.owner.getLogger().log(Level.INFO, " Player is looking up (y + 0.8, normal = 0.5)");
}
if (hitter.isSneaking()) {
yFactor = 0.95D;
directionFactor = 0.0D;
this.ballSpeedRegulator.setMaxFallSpeed(0.18D);
this.owner.getLogger().log(Level.INFO, " Player is looking up (y + 1.6, reduced fall)");
}
Vector velocity = hitter.getLocation().getDirection().clone().multiply(hitter.isSneaking() ? 0.0D : 2.55D);
if (yFactor != 0.0D && (velocity.getY() > 0 || hitter.isSneaking())) {
velocity.setY(yFactor);
}
if (directionFactor != 0.0D) velocity.multiply(directionFactor);
getBall().setVelocity(velocity);
this.owner.getLogger().log(Level.INFO, "----------------------------------------");
}
@sterile elm ping
@golden lotus
yFactor += 3.0D; too large]
0 to 1
if it's a vector element
its usign unit vectors where all 3 axis add up to 1.
Hmmm didn't know that
you then multiply that to increase the length
So it does make sense
Cool
if (hitter.getLocation().getPitch() < -85.0F)
Isn't this checking pitch tho
well I've nto looked over it to see if it will work
As in the direction a player is looking
Meaning it's setup direction dependant
Like it has to be made facing a specific direction
why are you worrying about pitch?
I believe it's to be able to return the ball towards the desired direction
It's volleyball, have to simplify it a bit otherwise it's too hard for the player
If it's "fine" direction then return it
So the arena is made facing a direction
would you not simply shoot the ball in the direction they are facing?