Hey guys, I have a runnable that goes of ever x ticks to check if a player is within a "invisible wall" then if they are use this Code: Vector direction = player.getLocation().getDirection(); player.setVelocity(direction.setY(-0.5).multiply(-1)); to fling them out of it. Problem is if they go backwards into the invisible wall, it flings them through it.
@jolbol1 Instead of manually setting the value for the vector, try reversing it. (so if a value is 1, make it -1)
@jolbol1 See if they are at the x max of the border, if so, fling them at a negitive x for x. If they are at x min, fling them in a positive X.
Like this? Code: Vector direction = player.getLocation().getDirection(); player.setVelocity(direction.setY(direction.getY() * -1).multiply(0.2));
@jolbol1 I have absolutely no idea what you're doing, since the line of code will not work. I think he means Code: int throwx = 1; int throwz = 1; if(player.getLocation().getX > maxlimit) throwx=-throwx; player.setVelocity(new Velocity(throwx,1,throwz))
Im just getting confused and Im not sure why. To make sure we are all on the same page. The invisible wall is a 1 block thick wall, and you could just walk round it, but I do plan to put blocks there. As such its sort of a invisible door, and If you have permission you can pass through., If you dont it hits you back.
@jolbol1 Code: //This is the field the controls the velocity of the x plane. int throwx = 1; //This is the field the controls the velocity of the z plane. int throwz = 1; //This if statement checks if the X is that greater than the wall, and if so, it will set the X plane to be negative(pushing the player back). If you only want the wall to be one block thick, swap '>' to '=' if(player.getLocation().getX = maxlimit) throwx=-throwx; //This if statement checks if the Z is that greater than the wall, and if so, it will set the Z plane to be negative(pushing the player back). If you only want the wall to be one block thick, swap '>' to '=' if(player.getLocation().getZ = maxlimit) throwz=-throwz; //this void will set the players velocity. player.setVelocity(new Velocity(throwx,1,throwz))