I want to be able to do this, but not go outside of the 4.4 meter limit, the radius is 4.4 meters, and it has zero gravity and no friction. I have a hard time explaining this, but imagine holding a hollow sphere with a little ball inside, when you shake it around the ball goes around the inside, I need something like that, but with zero gravity and no friction. I wasn't really sure how to do this, but I tried:
void Slide() {
if (slide) {
for (uint32_t deviceIndex = 0; deviceIndex < vr::k_unMaxTrackedDeviceCount; deviceIndex++) {
glm::vec3 position = devicePos[deviceIndex].xyz();
if (sqrt(pow(position.x - 0.35, 2) + pow(position.y + 1.75, 2) + pow(position.z + 0.85, 2)) >= 4.4) {
if (abs(position.x) > abs(position.y) && abs(position.x) > abs(position.z)) {
if (position.x > 0) {
velocity.x = ((abs(velocity.y)) + (abs(velocity.z))) / 2;
}
else {
velocity.x = ((abs(velocity.y) * -1) + (abs(velocity.z) * -1)) / 2;
}
}
if (abs(position.y) > abs(position.x) && abs(position.y) > abs(position.z)) {
if (position.y > 0) {
velocity.y = ((abs(velocity.x)) + (abs(velocity.z))) / 2;
}
else {
velocity.y = ((abs(velocity.x) * -1) + (abs(velocity.z) * -1)) / 2;
}
}
if (abs(position.z) > abs(position.x) && abs(position.z) > abs(position.y)) {
if (position.z > 0) {
velocity.z = ((abs(velocity.x)) + (abs(velocity.y))) / 2;
}
else {
velocity.z = ((abs(velocity.x) * -1) + (abs(velocity.y) * -1)) / 2;
}
}
}
}
}
}