Jump problems and Jerky movement.

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
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Jump problems and Jerky movement.

Post by disanti »

Question #1:
My game is using the following code to jump:

Code: Select all

	void jump(ITriangleSelector* selector)
	{
		jump_increment++;
		ISceneCollisionManager* scmgr = psmgr->getSceneCollisionManager();
		if(jump_increment < 80)
		{
			vector3df postriangle;
			triangle3df triangle;
			vector3df pcampos = pcamera->getPosition();
			bool colliding = scmgr->getCollisionPoint(line3d<f32>(
				pcampos,vector3df(pcampos.X,pcampos.Y+5.0f,pcampos.Z)),
				selector,postriangle,triangle);
			if(colliding==false)
			{
				pcamera->setPosition(vector3df(pcampos.X,pcampos.Y+2.0f,pcampos.Z));
			}
			else
			{
				isJumping = false;
				jump_increment = 0;
			}
		}
		else
		{
			jump_increment = 0;
			isJumping = false;
		}
	};
When the game is fullscreen, the jumping code makes the player jump about 8 times in a row, however when it is windowed, he only jumps once but alot higher. How does that work?

Question #2:
I've seen this question around here before but why do my player's guns always stay 1 frame behind?

Code in the main game loop:

Code: Select all

		//move the guns
		vector3df tempos = camera->getPosition();
		droid.setposition((int)tempos.X,(int)tempos.Y,(int)tempos.Z);
		tempos = camera->getRotation();
		droid.setrotation((int)tempos.X,(int)tempos.Y,(int)tempos.Z);
Final Question:
How would I go about making bullet holes when using the TechDemo's shooting code?

Low Priority Question :P :
Annoying warnings in this code:

Code: Select all

	float temphealth = (float)(droid.gethealth() / 100.0f)*32.0f;
	if(droid.gethealth() > 50)
	{
		driver->draw2DImage(hud_battery,
			core::position2d<s32>(70,GAME_RESY-40+(32-(32*temphealth))),
			core::rect<s32>(0,0,16,(int)32.0f*temphealth), 0, 
				video::SColor(255,255,255,255), true);
	}
	else if(droid.gethealth() > 30 && droid.gethealth() < 50)
	{
		driver->draw2DImage(hud_battery,
			core::position2d<s32>(70,GAME_RESY-40+(32-(32*temphealth))),
			core::rect<s32>(0,0,16,(int)32.0f*temphealth), 0, 
				video::SColor(255,255,255,0), true);
	}
	else
	{
		driver->draw2DImage(hud_battery,
			core::position2d<s32>(70,(int)GAME_RESY-40+(32-(32*temphealth))),
			core::rect<s32>(0,0,16,(int) 32.0f*temphealth), 0, 
				video::SColor(255,255,0,0), true);
	}
warnings:

Code: Select all

game.cpp
D:\Santi Productions\PSS4086\src\game.cpp(298) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
D:\Santi Productions\PSS4086\src\game.cpp(299) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
D:\Santi Productions\PSS4086\src\game.cpp(305) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
D:\Santi Productions\PSS4086\src\game.cpp(306) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
D:\Santi Productions\PSS4086\src\game.cpp(312) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
D:\Santi Productions\PSS4086\src\game.cpp(313) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
I can't figure this one out. I know that the float temphealth is causing it but I don't know how to fix it.

Thanks everyone!
~ John DiSanti
________
Methadone rehab dicussion
Last edited by disanti on Tue Feb 22, 2011 7:59 am, edited 2 times in total.
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Post by disanti »

Ok, I've solved the warnings. I was using a bad formula and came up with a new one which actually works better too! :P
________
GLASS PIPES
Last edited by disanti on Tue Feb 22, 2011 7:59 am, edited 1 time in total.
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Post by disanti »

Another quick question (this is becoming my question thread :P)

How do I position my bullets in front of my gun instead of right on top of my character?

core::vector3df start = camera->getPosition();

I have two guns on the screen at once, I also know that SupaG positions the bullets (from what I saw in the screenshot) at the tip of the guns. How can I do this?

Thanks!
________
HONDA LOGO
Last edited by disanti on Tue Feb 22, 2011 7:59 am, edited 1 time in total.
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Post by [dx/x]=HUNT3R »

I don't have it working exactly perfect yet in Supa G, but I get the target vector and the up vector and take their cross product to get a strafe vector (a vector that runs sideways thru the camera). Then I just normalize it to a unit vector and set the starting points of the bullets along the strafe vector by multiplying the normalized strafe vector by <10,10,10> and by <-10,-10,-10> which puts them "exactly" 10 units to the left and right of the camera. The bullets move so fast that it looks like they come out of the guns. Otherwise I do the bullets the same as Niko's techdemo.

Alternatively, you might could find the 2D screen coordinates of your gun's tip and just translate that into 3D coordinates for the starting point of a bullet, but I haven't tried that.
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Post by disanti »

Exactly what do you mean?

I get the target vector (done).
I make a cross product to get a strafe vector???
________
No2 Vaporizer
Last edited by disanti on Tue Feb 22, 2011 7:59 am, edited 1 time in total.
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Post by disanti »

Ok, I tried implementing your Supa-G shooting code and it seems very buggy, the bullets don't even appear sometimes. :? Right now I'm reverting back to the techdemo shooting. I will figure out something sometime :(

I have no clue why the bullets delete themselves upon creation. If I'm in an open space they don't destroy themselves though. Odd.
________
Free Gift Card
Last edited by disanti on Tue Feb 22, 2011 7:59 am, edited 1 time in total.
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Post by disanti »

My project is getting some very serious problems :( I'm thinking I will have to recode because the debugger isn't working at all. It always gives the same bogus error at the same place and there is nothing I can do about. Here I am recoding again. This time I will use more OOP though :P because this time I was just learning more about OOP, I should know enough now to get this game going...

Wish me luck ;) for this time :?
________
GIRLFRIEND PIC
Post Reply