[quote=“gunnar.kriik”]Hey,
So you just want to rotate the camera around a target node, if I understand you correctly. Shouldn’t be more difficult than this:
// Class member variable
float cameraYaw = 0.0f;
// Run each frame update
void UpdateCameraRotation(float deltatime, Node* targetNode) {
cameraYaw += 60.0 * dt; // Rotate camera N degrees each second
Quaternion q = Quaternion(cameraYaw, Vector3::UP); // Construct rotation
Vector3 cameraOffset(0.0f, -3.0f, 5.0f); // Camera offset relative to target node
Vector3 cameraPosition = targetNode->GetPosition() - (q * cameraOffset); // New rotated camera position with whatever offset you want
camera->SetPosition(cameraPosition); // Set new camera position and lookat values
camera->LookAt(target->GetPosition());
}
I just tried this code but kinda lost on it or should i be doing it different.
[code]void ExistenceClient::CameraOrientationRotateMove (float degrees, int movement)
{
/// get the button that was clicked
Renderer* renderer = GetSubsystem();
Graphics* graphics = GetSubsystem();
UI* ui_ = GetSubsystem();
/// The camera will use default settings (1000 far clip distance, 45 degrees FOV, set aspect ratio automatically)
Node * cameraNode_ = scene_->GetChild("Camera",true);
Node * playermeshNode_ = scene_->GetChild("playermesh",true);
/// get position
Vector3 playermeshPosition=playermeshNode_->GetPosition();
Vector3 cameraPosition=cameraNode_->GetPosition();
/// Create a offset
Vector3 cameraOffset=cameraPosition-playermeshPosition;
Quaternion q = Quaternion(1,Vector3(0.0f,1.0f,0.0f)); // Construct rotation
Vector3 cameranewPosition = playermeshPosition- (q * cameraOffset);
cameraNode_->SetPosition(cameranewPosition); // Set new camera position and lookat values
return;
}
[/code]