Camera view problem
How to change the camera view when an object had reach a certain point? i had try assign a flag to the object and using if else statement but it doesn't work. Please Help.
That really does not tell anyone enough information to help you. It would help greatly if you give us some more details on what your using. Also you should post the portions of code that are not functioning as expected. Without that information, we can only take guesses at thin air.
thank for the reminding... this is the part of the code that is no functioning...
if(GameWorld)
{
camVect = CVECTOR(390.0,600.0,600.0);
camera->setPosition(camVect);
camera->setLookAt(CVECTOR(400.0,-7000.0,-5000.0));
}
else if(GameWorld->cube->status =1 )
{
camVect = CVECTOR(390.0,600.0,600.0);
camera->setPosition(camVect);
camera->setLookAt(CVECTOR(200.0,-3000.0,-5000.0));
}
GameWorld is the scene that i want to display currently.i want the camera to change it view point to another object so i set a flag which is called status. so when the cube reach a certain point, the status which is originally 0 will become 1 and the camera will change it view point. itry this but it doesn;t work for me.
if(GameWorld)
{
camVect = CVECTOR(390.0,600.0,600.0);
camera->setPosition(camVect);
camera->setLookAt(CVECTOR(400.0,-7000.0,-5000.0));
}
else if(GameWorld->cube->status =1 )
{
camVect = CVECTOR(390.0,600.0,600.0);
camera->setPosition(camVect);
camera->setLookAt(CVECTOR(200.0,-3000.0,-5000.0));
}
GameWorld is the scene that i want to display currently.i want the camera to change it view point to another object so i set a flag which is called status. so when the cube reach a certain point, the status which is originally 0 will become 1 and the camera will change it view point. itry this but it doesn;t work for me.
Quote:Original post by caitsith_815That looks very wrong. What you're saying is if GameWorld exists (is not NULL) do the first block, otherwise check GameWorld's cube's status. If the else if condition is ever tested it will be an access violation because GameWorld is NULL. If testing that wouldn't be an access violation than GameWorld is not NULL and the first condition will always pass, so it will never reach the else if statement.if(GameWorld){ ...}else if(GameWorld->cube->status =1 ){ ...}
how can i solve this ? i try putting the else if statement into the if statement but it will ended up execute the else if statement first.
if(GameWorld->cube->status != 1)
{
// do first camera transform
}
else
{
// do the second camera transform
}
{
// do first camera transform
}
else
{
// do the second camera transform
}
Does this look like it might work?
(also note the ==)
Tim
camVect = CVECTOR(390.0,600.0,600.0);
camera->setPosition(camVect);
if(GameWorld->cube->status == 1 )
camera->setLookAt(CVECTOR(200.0,-3000.0,-5000.0));
else
camera->setLookAt(CVECTOR(400.0,-7000.0,-5000.0));
(also note the ==)
Tim
camVect = CVECTOR(390.0,600.0,600.0);
camera->setPosition(camVect);
if(GameWorld->cube->status == 1 )
camera->setLookAt(CVECTOR(200.0,-3000.0,-5000.0));
else
camera->setLookAt(CVECTOR(400.0,-7000.0,-5000.0));
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement