• Advertisement
Sign in to follow this  

Camera view problem

This topic is 4229 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Quote:
Original post by caitsith_815
if(GameWorld)
{
...
}
else if(GameWorld->cube->status =1 )
{
...
}
That 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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
if(GameWorld->cube->status != 1)
{
// do first camera transform
}
else
{
// do the second camera transform
}

Share this post


Link to post
Share on other sites
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));

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement