Better way to go up/down slope based on yaw?
- by CyanPrime
Alright, so I got a bit of movement code and I'm thinking I'm going to need to manually input when to go up/down a slope. All I got to work with is the slope's normal, and vector, and My current and previous position, and my yaw.
Is there a better way to rotate whether I go up or down the slope based on my yaw?
Vector3f move = new Vector3f(0,0,0);
move.x = (float)-Math.toDegrees(Math.cos(Math.toRadians(yaw)));
move.z = (float)-Math.toDegrees(Math.sin(Math.toRadians(yaw)));
move.normalise();
if(move.z < 0 && slopeNormal.z > 0 || move.z > 0 && slopeNormal.z < 0){
if(move.x < 0 && slopeNormal.x > 0 || move.x > 0 && slopeNormal.x < 0){
move.y += slopeVec.y;
}
}
if(move.z > 0 && slopeNormal.z > 0 || move.z < 0 && slopeNormal.z < 0){
if(move.x > 0 && slopeNormal.x > 0 || move.x < 0 && slopeNormal.x < 0){
move.y -= slopeVec.y;
}
}
move.scale(movementSpeed * delta);
Vector3f.add(pos, move, pos);