Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
saarwii's avatar
saarwii
Honored Guest
11 years ago

Checking the camera rotation and controlling it

So im working with a point and klick style game, actually it's a research and design project for my bachelor thesis in interaction design. anyway...

Point and klick style game using a tablet as an input device. it's first person game where i control an object in the game space that acts like a wayPoint for the player to go to. When i double tap the screen the player moves to the point of the object. I've done my own charactercontoller script for this. The player object consist of a character model object and the OVRCameraController as a child to it so when i move the character around in the game, the camera follows. So you can say that i've created my own OVRPlayerController. When the player starts moving towards the desired point, the whole character modell rotates to face the point where it's moving.

Now to my problem. I want to be able to compare the rotation of the OVRCamera (which is a child of the character model) and the character model or check so that they are facing the same way. This is to tell OVRCamera when to rotate.

i stumbled on to a solution of force rotating the camera:

OVRCameraController cameraController;

public float YRotation = 0.0f;
public float rotateInfluence ;
public float RotationAmount = 1.5f;
public float MoveScaleMultiplier= 1.0f;
public float RotationScaleMultiplier = 1.0f;

void Start(){
cameraController = GameObject.FindGameObjectWithTag("OVRCameraController").GetComponent<OVRCameraController>();
}
void Update(){
rotateInfluence = Time.deltaTime * RotationAmount * RotationScaleMultiplier;
YRotation -= rotateInfluence * 5f;
cameraController.SetYRotation(YRotation);
}


RotationAmount can be sett to rotate the camera. So my thought was (in psudocode)

if(OVRCamera.rotation > playerObject){
Rotationamount = -1;
}
ifif(OVRCamera.rotation < playerObject){
Rotationamount = 1;
}
or if(OVRCamera.direction != playerObject.direction){
Rotationamount = -1;
}


and so on and so on. But for this solution i must be able to read the real rotataion variabels of the OVRCameraController object

2 Replies

Replies have been turned off for this discussion
  • Anonymous's avatar
    Anonymous
    I believe you should actually be able to just skip all that and drag your same character transform to the "Follow Orientation" field in the OVRCameraController. Have you given that a shot?
  • saarwii's avatar
    saarwii
    Honored Guest
    "phillipfoshee" wrote:
    I believe you should actually be able to just skip all that and drag your same character transform to the "Follow Orientation" field in the OVRCameraController. Have you given that a shot?



    i....am.....sooooooo...stupid....It works great!! i think i've been sitting with kod so much the last couple of days that solutions are just starting to slipp through my mind