Player floats above ground.

Posted By: emo10001

Player floats above ground. - 07/10/11 23:37

After adding shadows to my model...my suspicion that he was floating was confirmed. I looked at another post here about floating models, but the only answer given was that "something should be a negative number instead".

I'm using the "Improved Player Movement" script from the wiki ( http://www.opserver.de/wiki/index.php/Improved_Player_Movement )

While I think I understand the basics of c_trace...I'm certainly no expert. This is what I'm getting:





I can move my player just fine....but he's always that high above my terrain.

Snippets of the code are
Code:
//determine player height
	c_setminmax(my);
	wait(1);
	var feedheight = -my.min_z;

		//check distance to ground
		grounddist = c_trace(my.x, vector(my.x, my.y, my.z-10000), IGNORE_ME|IGNORE_PASSABLE)-feedheight;
		if(grounddist > 0 || movedir.z < 0)
		{
			//gravity acceleration
			movedir.z += fallacc*time_step;
		}else
		{
			movedir.z = 0;
		}
		
		//apply gravity
		my.z -= minv(movedir.z*time_step, grounddist);
		
		if(grounddist-minv(movedir.z*time_step, grounddist) == 0)
		{
			//jump
			if(key_space)
			{
				movedir.z = -jumpacc;
			}
		}



Any thoughts?
Posted By: Walori

Re: Player floats above ground. - 07/11/11 08:03

Make sure your bounding box is correctly shaped (hit f11 two times in a row to check) as this looks like the bounding box is below players feet. For this reason code assumes the player is on the ground even if this wouldn't be the case.
Posted By: Ceryni

Re: Player floats above ground. - 07/11/11 08:58

have you tried vec_for_min like in the tutorial for a shooter?
if you cant move anymore set my.z+2 before moving so after it it will be set to ground again and you wont see it.
Posted By: Anonymous

Re: Player floats above ground. - 07/13/11 02:03

I had the same problem this change fixed it.

var feedheight = -(my.min_z+2);

play with 2 till you get the right value.
Posted By: emo10001

Re: Player floats above ground. - 07/14/11 02:50

Malice that got it. I had to play with 2 a little...but that did it. And it's not allowing me to really adjust my bounding box the way I want it.

Thanks for the heads up. Thanks to everyone who replied. This is a great community
Posted By: Arrovs

Re: Player floats above ground. - 07/19/11 22:16

it should use c_move
and vhy feed height at all?
Vizout it vorks good anyvay.
But im just asking, nothing personal.
Posted By: Anonymous

Re: Player floats above ground. - 07/19/11 22:31

I changed it to c_move in my copy. But you still have to adjust feedheight with a positive number.
© 2024 lite-C Forums