Longer jumping
Longer jumping
hey,
I don't know if this really should be in beginner's help but I'm awfully new to the irrlicht engine, so I thought this would be best:
I created a camera and added a jump command to it (changed left,up,right,down to WASD and added the jump command)
I've got the camera jumping set to 0.8f
when I don't hold the space key it immediately returns to the ground. This way you CAN jump over gaps but if you don't hold the space key you'll keep falling in it.
MAIN QUESTION: How can I get the jump to continue when the space key is not being hold?
SOLVED!!!! SECOND QUESTION: How can I disable the 'mouse-jumping'. I don't want the camera to jump when I face up and press forward.
SOLUTION: generate a key map with a JUMP action, but set jumping to false. This way the camera will jump when using the appropriate key but it won't when you face up.
THIRD (OPTIONALLY, I FIRST HAVE TO GET THE JUMPING RIGHT) QUESTION: Is there a way to like... use a vector for jumping... cause I'm looking for a way to do 'hero'-jumps... you know, those jumps that seem like there is no gravity and don't go very fast so you can have a look around a bit like in that game... uhm...GTA-like game where you can mod your powers and then enable rooftop-to-rooftop-jumping
I don't know if this really should be in beginner's help but I'm awfully new to the irrlicht engine, so I thought this would be best:
I created a camera and added a jump command to it (changed left,up,right,down to WASD and added the jump command)
I've got the camera jumping set to 0.8f
when I don't hold the space key it immediately returns to the ground. This way you CAN jump over gaps but if you don't hold the space key you'll keep falling in it.
MAIN QUESTION: How can I get the jump to continue when the space key is not being hold?
SOLVED!!!! SECOND QUESTION: How can I disable the 'mouse-jumping'. I don't want the camera to jump when I face up and press forward.
SOLUTION: generate a key map with a JUMP action, but set jumping to false. This way the camera will jump when using the appropriate key but it won't when you face up.
THIRD (OPTIONALLY, I FIRST HAVE TO GET THE JUMPING RIGHT) QUESTION: Is there a way to like... use a vector for jumping... cause I'm looking for a way to do 'hero'-jumps... you know, those jumps that seem like there is no gravity and don't go very fast so you can have a look around a bit like in that game... uhm...GTA-like game where you can mod your powers and then enable rooftop-to-rooftop-jumping
Last edited by xaddict on Fri Feb 01, 2008 2:28 pm, edited 3 times in total.
Re: Longer jumping
You have to save the state in a variable and perform adjusting coordinates properly.xaddict wrote: MAIN QUESTION: How can I get the jump to continue when the space key is not being hold?
Re: Longer jumping
I have no idea how to do that... I'm a complete newbie to the engine.greenya wrote:You have to save the state in a variable and perform adjusting coordinates properly.xaddict wrote: MAIN QUESTION: How can I get the jump to continue when the space key is not being hold?
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Bear in mind that Irrlicht is a 3D engine, not a game engine. The FPS camera is provided to a simple demo of what you can do, it's not intended to be used in a real game.
You could check out the code snippets / tutorials sections to see if anyone has created a suitable camera, although I'd recommend against making your movement logic part of a camera.
Sorry if this isn't the answer you wanted, but if you want to program a game you really are going to have to figure a lot of things out for yourself. If that doesn't appeal, you could try to find a full game engine that provides more of what you need.
You could check out the code snippets / tutorials sections to see if anyone has created a suitable camera, although I'd recommend against making your movement logic part of a camera.
Sorry if this isn't the answer you wanted, but if you want to program a game you really are going to have to figure a lot of things out for yourself. If that doesn't appeal, you could try to find a full game engine that provides more of what you need.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Great attitude! Go for it, tiger.
include/ICameraSceneNode.h
source/Irrlicht/CCameraFPSSceneNode.h
source/Irrlicht/CCameraFPSSceneNode.cpp
You could alter them directly in the engine, or you could just copy the .h and .cpp files into appropriate new files in your application code, and create a new custom camera type. As long as it's derived from ICameraSceneNode, Irrlicht will happily accept and use it just as it would any of its built in cameras.
And there's nothing magic about instantiating your custom camera in your application code: the appropriate code in CSceneManager.cpp does this:
So in your application code, you just need to do something like:
You must drop() the camera at some point because in its constructor it should create itself with a reference count of 1, then when it adds itself to its parent (the scene manager in this case) that increases the refcount to 2. You want it to be destroyed when the scene is destroyed during the device cleanup, so at that point it should have a reference count of 1. Thus you have to drop() it before dropping the device. Some of the examples call drop() early on, but I think this is very bad form; after you drop() an object, you should not assume that it is still valid, so drop() should be the last thing you do to an object, after you're done using it. YMMV though.
include/ICameraSceneNode.h
source/Irrlicht/CCameraFPSSceneNode.h
source/Irrlicht/CCameraFPSSceneNode.cpp
You could alter them directly in the engine, or you could just copy the .h and .cpp files into appropriate new files in your application code, and create a new custom camera type. As long as it's derived from ICameraSceneNode, Irrlicht will happily accept and use it just as it would any of its built in cameras.
And there's nothing magic about instantiating your custom camera in your application code: the appropriate code in CSceneManager.cpp does this:
Code: Select all
ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent,
f32 rotateSpeed, f32 moveSpeed, s32 id,
SKeyMap* keyMapArray, s32 keyMapSize, bool noVerticalMovement,f32 jumpSpeed)
{
if (!parent)
parent = this;
ICameraSceneNode* node = new CCameraFPSSceneNode(parent, this, CursorControl,
id, rotateSpeed, moveSpeed, jumpSpeed, keyMapArray, keyMapSize, noVerticalMovement);
node->drop();
setActiveCamera(node);
return node;
}
Code: Select all
ISceneManager* smgr = device->getSceneManager();
//...
CMyCustomCamera * myCustomCamera = new CMyCustomCamera(smgr, smgr, any, other, parameters);
smgr->setActiveCamera(myCustomCamera);
//... at some point before finally dropping the device
myCustomCamera->drop(); // [* see below]
You must drop() the camera at some point because in its constructor it should create itself with a reference count of 1, then when it adds itself to its parent (the scene manager in this case) that increases the refcount to 2. You want it to be destroyed when the scene is destroyed during the device cleanup, so at that point it should have a reference count of 1. Thus you have to drop() it before dropping the device. Some of the examples call drop() early on, but I think this is very bad form; after you drop() an object, you should not assume that it is still valid, so drop() should be the last thing you do to an object, after you're done using it. YMMV though.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
rogerborg wrote:...you could try to find a full game engine that provides more of what you need.
Official Site: http://NUSoftware.sourceforge.net
Official Forum: http://NUSoftware.sourceforge.net/phpBB2/index.php
P.S
It's pretty new and lacks a lot but it can help you start..
The jumping while the camera faces the sky is not implemented in the FPS scripts... I guess it's a check...
See I use the quake tutorial... with collision detection. When you make the camera face the sky it jumps a little but less than a normal jump. I think this is because the colision is not completely accurate or has a delay causing the camera to move a little bit up and then a bit down... Any idea how to get rid of this?
EDIT: ABOVE SOLVED...
Now I only need the main question solved... writing a new camera will be hard. I'm not gonna do that. But I guess there should be a way if a key (space) is triggered set a certain movement in the air (a tan or cos perhaps) which causes the camera to not return immediately but stay in the air until the jump ends... any ideas? I'll have to go with a Greenya Approach I guess.. saving the jump state in a variable... and making a 3d vector (like a ball being thrown) to make me jump in the right direction.
See I use the quake tutorial... with collision detection. When you make the camera face the sky it jumps a little but less than a normal jump. I think this is because the colision is not completely accurate or has a delay causing the camera to move a little bit up and then a bit down... Any idea how to get rid of this?
EDIT: ABOVE SOLVED...
Now I only need the main question solved... writing a new camera will be hard. I'm not gonna do that. But I guess there should be a way if a key (space) is triggered set a certain movement in the air (a tan or cos perhaps) which causes the camera to not return immediately but stay in the air until the jump ends... any ideas? I'll have to go with a Greenya Approach I guess.. saving the jump state in a variable... and making a 3d vector (like a ball being thrown) to make me jump in the right direction.
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
I think you're doing the right thing by eschewing camera based movement logic. It's really the wrong place to put it; it's only in there because it makes doing simple demos much more convenient.
Slaving a regular (not FPS) camera to another node that has physical presence (e.g. a collision ellipse) is a much more general solution, as you'll be able to use the physical presence node for actors other than your player avatar.
Slaving a regular (not FPS) camera to another node that has physical presence (e.g. a collision ellipse) is a much more general solution, as you'll be able to use the physical presence node for actors other than your player avatar.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
sorry if this doesn't work at all i have not looked into this at all and i am still a novice programmer but you could possibly try this basic setup. first set up a collision system with the floor and the camera, then make an if statement so if the camera is on the ground and you press space it runsand then do something similar to make it go slowly down.
PS. this code is not accurate as far as i know this is just to show basicly what you could do.
Code: Select all
for(camera posx, camera posx < camera max posx, camera posx + .8)
PS. this code is not accurate as far as i know this is just to show basicly what you could do.
this is a nice start but I have to take everything in account... I use multiple meshes thus have to set up multiple collision detection. My camera moves in 3D space... so if running in an XZ the movement should be faster in both directions and when jumping the jump has to be correct too...wizecoder wrote:sorry if this doesn't work at all i have not looked into this at all and i am still a novice programmer but you could possibly try this basic setup. first set up a collision system with the floor and the camera, then make an if statement so if the camera is on the ground and you press space it runsand then do something similar to make it go slowly down.Code: Select all
for(camera posx, camera posx < camera max posx, camera posx + .8)
PS. this code is not accurate as far as i know this is just to show basicly what you could do.
I will try to set this up though, thanks for your help:)