Game Development Community

Issue with my character bobbing up and down

by Ray Gebhardt · in Torque Game Builder · 03/06/2005 (12:57 pm) · 20 replies

I am having a issue with my character bobbing up and down when he walks. I am making a platformer style game, where the physics are similar to a game like Super Mario Brothers. I apply a constant force to the scene so that all objects are pulled towards the ground. Then I apply a constant force to the character to make him walk back and forth. The problem is, when the character touches one of the "seams" in a tilemap collision polygon, he kind of gets caught on it. This makes the character bump up a little when he hits it. If you are going really slow, in some cases it will actually stop him from moving.

I configured the collision material for the character as follows:
datablock fxCollisionMaterialDatablock2D(knightMaterial)
{
	friction = 0.0;
	restitution = 0.0;
	relaxation = 0.3;
	density = 0.01;
	forceScale = 1;
	damping = 0.1;
};

I setup the collision material as follows (I set the desitiy to 0.0 so that the tilemaps don't get effected by the gravity):
datablock fxCollisionMaterialDatablock2D(tileMaterial)
{
	friction = 0.0;
	restitution = 0.0;
	relaxation = 0.0;
	density = 0.0;
	forceScale = 1;
	damping = 0.1;
};

To create gravity for the scene I did the following (I set the gravitic field to false, because it didn't do anything, no matter what value I set it to):
t2dSceneGraph.setConstantForce("0 10000", false);

To make sure my character wouldn't rotate around, I set his maximum angular velocity as follows:
%this.sceneObject.setMaxAngularVelocity(0);

Finally to move the character I did something like the following:
%this.sceneObject.setConstantForce("5000 0");

Anyone know how to tweak the physics to make it so my character won't bob up and down when walking?

#1
03/06/2005 (1:06 pm)
I too have a similar problem of hitting each tile. If I get a fix will post it
#2
03/06/2005 (2:18 pm)
Actually come to think of it i should have also added that I am setting everything to a size of "14 14". The tile collision polygons are still created correctly though. I use something like the method LabRat posted to make sure the collision polygons are created correctly. I also checked the collision polygons in debug mode, just to make sure everything was setup correctly.
#3
03/06/2005 (2:45 pm)
@Ray: This has already been reported here.

We really should get a more visible and central method so people can check on stuff. Most of my posts this evening are redirecting people to existing problems. :(

- Melv.
#4
03/06/2005 (2:52 pm)
I try to keep up with the posts, but sometimes I miss one or two. :)
#5
03/06/2005 (5:37 pm)
I'm going to keep the Torque 2D Unofficial Faq updated as much as possible


[url]http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7298]Torque 2D Unofficial FAQ[/url]

just check it so it notifies you and I'll see if I can update this on a daily basis

(I made a system so I can generate html (with linking formating etc) as well as forum happy files so I can keep this updated easier :)
#6
03/07/2005 (12:59 am)
@Ray: Sorry man, I guess I need to sleep more. Didn't want to sound harse. Sorry about that.

@Matthew: Thanks for helping-out, you've been extremely helpful over the last week.

If you haven't already figured it out guys, just ignore me when I get grumpy. It must be my age or something. ;)

- Melv.
#7
03/07/2005 (6:13 am)
@Melv: or maybe the sleep deprivation from the past few months of working on your amazing engine! As well as all the time you spend now working on it and on the forums, if I can help you dedicate more time to the engine vs the forums then I'm helping more than I could in any other way :)

lol A selling point I always use for T2D is that the main creator responds to practically every forum post! ... and theres already over 1500 posts ! (in hardly over a week).

A teammate of mine uses Gamemaker, he went to the Gamemaker forums and asked them a question... they literaly laughed at him and insulted him... its an amazing contrast !
#8
03/07/2005 (6:30 am)
Thanks Matthew, that made me feel a little less burned.

Had a break from the forums for 1.5 days and I felt really bad. :)

Again, thanks, it all helps.

- Melv.
#9
03/07/2005 (12:51 pm)
Yeah, Melv, honestly.. unless it's something nobody else will answer, give us some time to post while you do T2D voodoo. You're usually all over the answers before anyone else can help you respond! :)
#10
03/07/2005 (1:20 pm)
:)

Will do.

- Melv.
#11
03/08/2005 (11:26 am)
I wasn't having this problem until I started rewriting my player code to use a state machine to handle the movement. Right now, when my player moves to the right, all is well, but when he moves to the left, he bounces up and down as he goes. I set the friction in both materials to 0 to see if that suggestion might have worked but it didn't. Same exact behavior. It's odd that it does it moving one direction but not the other, especially considering the code is the same except that I negate the force direction.
#12
03/08/2005 (11:30 am)
@Seth: If you want to forward a code example to me, I'll look at it to see if it's something in T2D or perhaps something you may be doing wrong.

- Melv.
#13
03/10/2005 (3:20 pm)
I think the EA of T2D was very well done. The only issues that I couldn't resolve where this one, and the texture bleeding. If you could bump this issue up the list some, then I would have everything I need to finish my game! :) If you need a snapshot of my game's current code to see what the issue is, I can sent you a copy. Its still kind of top secret at this point, but if it fixes my issue, I would be more than happy to. :)
#14
03/11/2005 (1:29 am)
I'm hoping to resolve all the current outstanding issues but some of them require adding stuff we wanted to defer until later so it's just taking a little longer to get out than expected.

Thanks for your praise on the T2D release.

We're working our butts-off to get all the initial wave of bugs squashed. Should be a good update. :)

- Melv.
#15
08/03/2005 (1:08 pm)
I have a fix for this issue that I just came up with. I don't think its the most correct way to fix it, but it worked with my game.

http://www.garagegames.com/mg/forums/result.thread.php?qt=32967
#16
08/04/2005 (1:21 am)
I'd just like to note that there is a permanent fix for this in the next release. I'd post the offending routines but there is such a difference between the v1.0.2 release and what we've got here that it would be impossible without posting everything.

If anyone is interested, I can provide a pointer. I omitted a little piece of code at the end of "t2dSceneObject::checkCollisionSend()" which was supposed to sort the collisions before reporting/handling them. In-fact, only the first temporal one should be dealt with. Without this sort, the objects are dealt with in the order they are returned from the broad-phase container-bins. This was handled correctly in "t2dSceneObject::castCollision()" albeit not the way it is now. As you slide over the the tiles, the system is returning multiple tiles that the object would collide with. If these are dealt with out-of-order, you can potentially deal with an adjacent tile (or object) first and can result in an impact on the side/vertex of a tile.

There are other contributing factors but this one is the biggest problem and with this change alone, it should solve 'seam' problems for most people.

- Melv.
#17
08/04/2005 (6:19 am)
Melv, feel free to post everything. We won't mind.
#18
08/04/2005 (11:57 am)
That sounds cool Melv. My "fix" was just a little bit of an educated guess after fiddling around for a while. It worked for my game, so I thought it would help people out for at least the moment. I can't wait to get your real fix :)
#19
08/05/2005 (12:09 am)
No problem Ray. Although I've not had time to check your fix out, I'm actually interested in seeing what it does in cases there's another problem I've missed. You can't be too careful. :)

- Melv.
#20
08/05/2005 (6:35 am)
Well I don't know if it would really help, because I am not 100% sure why it actually fixes the issue in my game. :)