ICameraSceneNode XYZ position
-
- Posts: 27
- Joined: Mon Oct 30, 2006 11:55 pm
ICameraSceneNode XYZ position
Hey, I'm simply trying to acces and change the camera's Y coordinate. How do I do this?
You call ISceneNode::setPosition(). It takes a vector that represents the 3d position relative to the parent. If you wanted to move the camera up one unit, you would write this...
Code: Select all
core::vector3df pos = cam->getPosition();
pos.Y += 1.f;
cam->setPosition(pos);
-
- Posts: 27
- Joined: Mon Oct 30, 2006 11:55 pm
Thanks!
I've got another question :p
I'm trying to set really simple jumping this: But it doesn't work. Is it my input? I once tried shooting, and that too did not work. Am I doing the user input in correctly?
I've got another question :p
I'm trying to set really simple jumping this:
Code: Select all
void CJump::initPhysics() {
jumping = false;
falling = false;
jumpSpeed = 10.0;
gravity = 230.0;
}
void CJump::jump() {
if ((event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.PressedDown == true) )
{
switch( event.KeyInput.Key ) {
case KEY_SPACE:
if( jumping == false ) {
jumping = true;
}
}
}
if( jumping == true ) {
jumpSpeed -= 0.5;
gravity -= jumpSpeed;
}
if( gravity < 0 ) {
falling = true;
jumping = false;
}
if( (gravity < 230) && (falling == true) )
gravity += (jumpSpeed + 3);
if( gravity == 230 ) {
jumpSpeed = 10;
jumping = false;
falling = false;
}
if( gravity > 230 )
gravity = 230;
vector3df pos = GCamera::getCamera()->getPosition();
pos.Y = gravity;
GCamera::getCamera()->setPosition(pos);
}
Hey There.
Can't say I've tested this, but using this :
gravity can be set in the 'createCollisionResponseAnimator'
Can't say I've tested this, but using this :
Is just going to make the camera jump 'straight' to a position, rather than gracefully move.pos.Y = gravity;
GCamera::getCamera()->setPosition(pos);
gravity can be set in the 'createCollisionResponseAnimator'
Code: Select all
// create collision response animator and attach it to the camera
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(60,100,60),
core::vector3df(0,0,0), // set (0,-1,0) for gravity
core::vector3df(0,50,0));
camera->addAnimator(anim);
anim->drop();
You scratch my back, I'll scratch yours.