Longer jumping

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
xaddict
Posts: 23
Joined: Tue Jan 29, 2008 7:18 pm

Longer jumping

Post by xaddict »

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 :D 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.
spike314
Posts: 27
Joined: Sun Nov 19, 2006 11:51 am
Location: Shropshire (UK)
Contact:

Post by spike314 »

Hi xaddict

I not sure on your main question but as for the second one if you are using a FPS camera there is an option called "noVerticalMovement" just set that to true.
You can have all the power in the world but if you have no one to follow you what good is the power?
Morgawr
Posts: 95
Joined: Wed Sep 26, 2007 7:04 pm

Post by Morgawr »

mmm I think you should use physics for jumping? Irrlicht alone can't help much with physics in games I think, it provides only a "primitive" collision detection if I'm not wrong..

but I'm not good with physics and that kind of stuff, Irrlicht or not so I might be wrong
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Re: Longer jumping

Post by greenya »

xaddict wrote: MAIN QUESTION: How can I get the jump to continue when the space key is not being hold?
You have to save the state in a variable and perform adjusting coordinates properly.
xaddict
Posts: 23
Joined: Tue Jan 29, 2008 7:18 pm

Post by xaddict »

spike314 wrote:Hi xaddict

I not sure on your main question but as for the second one if you are using a FPS camera there is an option called "noVerticalMovement" just set that to true.
If I put that off it won't let me jump at all..
xaddict
Posts: 23
Joined: Tue Jan 29, 2008 7:18 pm

Re: Longer jumping

Post by xaddict »

greenya wrote:
xaddict wrote: MAIN QUESTION: How can I get the jump to continue when the space key is not being hold?
You have to save the state in a variable and perform adjusting coordinates properly.
I have no idea how to do that... I'm a complete newbie to the engine.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
xaddict
Posts: 23
Joined: Tue Jan 29, 2008 7:18 pm

Post by xaddict »

Nah I'm gonna try Irrlight... they make games with it so after going through tons of calculations and stuff I would/should be able to do that too:)

Is there maybe a .h file with the FPSCamera in it? Then I could alter that... I'm good in math so that shouldn't be a problem:P
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Great attitude! Go for it, tiger. :P

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;
}
So in your application code, you just need to do something like:

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
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

rogerborg wrote:...you could try to find a full game engine that provides more of what you need.
Image

Official Site: http://NUSoftware.sourceforge.net
Official Forum: http://NUSoftware.sourceforge.net/phpBB2/index.php

:D :twisted: 8)

P.S
It's pretty new and lacks a lot but it can help you start..
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
xaddict
Posts: 23
Joined: Tue Jan 29, 2008 7:18 pm

Post by xaddict »

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.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
wizecoder
Posts: 13
Joined: Thu Jan 03, 2008 9:36 pm

Post by wizecoder »

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 runs

Code: Select all

for(camera posx, camera posx < camera max posx, camera posx + .8)
and 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. :D
xaddict
Posts: 23
Joined: Tue Jan 29, 2008 7:18 pm

Post by xaddict »

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 runs

Code: Select all

for(camera posx, camera posx < camera max posx, camera posx + .8)
and 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. :D
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...

I will try to set this up though, thanks for your help:)
Post Reply