Moving the camera through a node..
-
- Posts: 16
- Joined: Sat May 06, 2006 4:36 am
Moving the camera through a node..
Ok, i have a little game for my project at school, its nothing special the camera is just the character. Since it will be on display i need a way of pressing a button to move the camera back to the starting location (its a maze game). Sounds easy enough but when i press the button to move it, it jsut runs into the nearest wall. So i figured it's because im trying ot move the camera through the wall nodes of hte maze... is there any way i can temporarily make the camera able to go through a wall then set back once im back at the starting location?
-
- Posts: 10
- Joined: Fri May 05, 2006 10:38 am
- Location: Australia
-
- Posts: 16
- Joined: Sat May 06, 2006 4:36 am
That's exactly what i do, but on its way back to the starting location it runs into a few walls wich i cannot pass through (and is not suposed to, as its a maze) what im asking is there sumthing i cna do before the camera.setPoisition() so that it cna move through the walls? and also how to set it back to normal once im there?
Yeah i had a problem like this and found it was due to the collision animator attached to the camera (unsurprisingly!). I never really found a way round it, i did try to remove the animator, move the camera, then reattach the animator but i don't think it worked (not sure what did happen though), but that might be something to try.
-
- Posts: 16
- Joined: Sat May 06, 2006 4:36 am
Tried that also, didn't hepl at all.
What i did try is, move camera straight up above the maze, move to where im now on top of where the maze starts, then bring it back down. I do this in the while loop and its updating so fast that it seems to just only do the last command, which ocne agian throws me into a wall.
What i did try is, move camera straight up above the maze, move to where im now on top of where the maze starts, then bring it back down. I do this in the while loop and its updating so fast that it seems to just only do the last command, which ocne agian throws me into a wall.
-
- Posts: 16
- Joined: Sat May 06, 2006 4:36 am
-
- Posts: 16
- Joined: Sat May 06, 2006 4:36 am
-
- Posts: 16
- Joined: Sat May 06, 2006 4:36 am
After weeks i finally figured it out. Though i don't understand it 100% it makes sense.
I would move the camera above the maze ( sicne hter was no roof)
then i would move it over above where i wanted it.
then i would birng it back down to avoid any collision.
even with updateAbsolutePosition() it would not update it fast enough it would jsut try to move it through the wall again.
so now what i do is:
move camera up
smgr->drawAll();
move camera atop the spot
smgr->drawAll();
bring it back down
smgr->drawAll();
and doing that within the if statement finally made it work.
Thanks for all the input and i hope this will help someone else out too ^_^
I would move the camera above the maze ( sicne hter was no roof)
then i would move it over above where i wanted it.
then i would birng it back down to avoid any collision.
even with updateAbsolutePosition() it would not update it fast enough it would jsut try to move it through the wall again.
so now what i do is:
move camera up
smgr->drawAll();
move camera atop the spot
smgr->drawAll();
bring it back down
smgr->drawAll();
and doing that within the if statement finally made it work.
Thanks for all the input and i hope this will help someone else out too ^_^
Could you not have achieved the same effect by removing the nodes collision animator, moving the node, and then adding the animator back?
Wait, nevermind. The collision animator is not smart enough to know it has been removed or added to a scene node. This should have worked though...
Code: Select all
player->removeAnimator(coll);
player->setPosition(newPos);
player->addAnimator(coll);
Code: Select all
// remove collision response animator from player
player->removeAnimator(coll);
coll = smgr->createCollisionResponseAnimator(...);
player->addAnimator(coll);
coll->drop();