• 3D
  • Problem with Bullet Physics and Character Movement

I started with a new game and have a problem with character movement. My character slows down when he is up (close to the red wall) and gets faster when he is close to the green wall at the bottom.

For testing I created a second character with a simple character control.

Here a screenshot from my scene setup

This problem only happens when physics is set to bullet physics and when the player control script has this line of code: "velocity.y += gravity * delta".

I don't know if this is a bug in godot or in my game...

For Testing you can find my project here

Update: I tried it with the newest version of godot and it still happens, but I tried a safe margin of 0.05 fixed this issue for me. I don't know if this has something todo with this (closed) issue.

Godot should not allow margin values below some value. Bullet physics have some issues and margin can help for some of those issues.

a month later

Bullet is 3d physics engine, I think your problem is elsewhere.

@rubberduck said: I started with a new game and have a problem with character movement. My character slows down when he is up (close to the red wall) and gets faster when he is close to the green wall at the bottom.

For testing I created a second character with a simple character control.

Here a screenshot from my scene setup

This problem only happens when physics is set to bullet physics and when the player control script has this line of code: "velocity.y += gravity * delta".

I don't know if this is a bug in godot or in my game...

For Testing you can find my project here

Try uploading the project somewhere and we can take a look.

@slapin said: Bullet is 3d physics engine, I think your problem is elsewhere.

There is physics bugs with Godot and Bullet physics when there is capsule landing on the edge of a cube , it can get stuck many times. Armory 3D is also using Bullet and there is some obvious bugs.

Bullet Physics doesn't mean it's bug free or its implementation is perfect and bug free ?

EDIT: Just read the second comment, and realized the question has already been answered and the problem fixed. My apologizes for not realizing that before! Feel free to ignore what I wrote :sweat_smile:

@rubberduck, I downloaded the project and I think I have fixed the problem.

I changed the code slightly and now it does not go any faster/slower when closer to one wall over another.

I would say I know what was causing the issue, but to be honest I had a hard time figuring out how the previous code worked, but that's probably just because I'm tired and has nothing to do with your code :lol:

I have attached Player.gd with my modifications, hopefully they help!

@MagicLord said: Try uploading the project somewhere and we can take a look.

There is a link to the project in the first post, at the bottom.

@slapin said: Bullet is 3d physics engine, I think your problem is elsewhere.

I downloaded the project and it is 3D rendered with a camera facing downwards, so Bullet is the physics engine being used. That said, I do not think Bullet is/was causing the issue (though I could be wrong!)

@MagicLord said: (In response to the above quote from slapin) There is physics bugs with Godot and Bullet physics when there is capsule landing on the edge of a cube , it can get stuck many times. Armory 3D is also using Bullet and there is some obvious bugs.

Nothing is getting stuck, or at least nothing was getting stuck when I tested the project.

(Slightly off topic, but...)

I have noticed that the capsule getting stuck on a edge of another physics object is a common bug, one I have found in almost every game engine / physics engine I have used (including Unity and Unreal). I think the reason that bug is so common is because it is a difficult problem to solve.

Bullet Physics doesn't mean it's bug free or its implementation is perfect and bug free ?

Agreed. Because software is written by people who occasionally make mistakes, there are going to be bugs/mistakes in the code. It is part of what makes computer science so interesting and, at times, frustrating :smile:

That said, I do not think anyone was saying Bullet is bug-free/perfect (or at least that is not the impression I got).

@TwistedTwigleg said: EDIT: Just read the second comment, and realized the question has already been answered and the problem fixed. My apologizes for not realizing that before! Feel free to ignore what I wrote :sweat_smile:

@rubberduck, I downloaded the project and I think I have fixed the problem.

I changed the code slightly and now it does not go any faster/slower when closer to one wall over another.

I would say I know what was causing the issue, but to be honest I had a hard time figuring out how the previous code worked, but that's probably just because I'm tired and has nothing to do with your code :lol:

I have attached Player.gd with my modifications, hopefully they help!

@MagicLord said: Try uploading the project somewhere and we can take a look.

There is a link to the project in the first post, at the bottom.

@slapin said: Bullet is 3d physics engine, I think your problem is elsewhere.

I downloaded the project and it is 3D rendered with a camera facing downwards, so Bullet is the physics engine being used. That said, I do not think Bullet is/was causing the issue (though I could be wrong!)

@MagicLord said: (In response to the above quote from slapin) There is physics bugs with Godot and Bullet physics when there is capsule landing on the edge of a cube , it can get stuck many times. Armory 3D is also using Bullet and there is some obvious bugs.

Nothing is getting stuck, or at least nothing was getting stuck when I tested the project.

(Slightly off topic, but...)

I have noticed that the capsule getting stuck on a edge of another physics object is a common bug, one I have found in almost every game engine / physics engine I have used (including Unity and Unreal). I think the reason that bug is so common is because it is a difficult problem to solve.

Bullet Physics doesn't mean it's bug free or its implementation is perfect and bug free ?

Agreed. Because software is written by people who occasionally make mistakes, there are going to be bugs/mistakes in the code. It is part of what makes computer science so interesting and, at times, frustrating :smile:

That said, I do not think anyone was saying Bullet is bug-free/perfect (or at least that is not the impression I got).

wow! looks like you have lots of experience!!! :o i wonder how long you been on gamedev?

@TwistedTwigleg said: I have noticed that the capsule getting stuck on a edge of another physics object is a common bug, one I have found in almost every game engine / physics engine I have used (including Unity and Unreal). I think the reason that bug is so common is because it is a difficult problem to solve.

Not sure i got this issue on Unreal 4, it doesn't uses Bullet physics but Nvidia physX.

@aztecsensei said: wow! looks like you have lots of experience!!! :o i wonder how long you been on gamedev?

Thanks, though I'm not sure if I'd count myself as experienced. I still feel like a beginner most of the time :lol:

As for how long I've been doing game development, I guess there are two answers:


(Realistic answer):

I have seriously been doing game development for the past four years or so. I started taking game development seriously when I started entering game jams and I realized I could actually make games people might like playing.

I then started researching and making lots of games without any tutorials/guides/templates as a way to really learn how games work. Many of the games were just prototypes and there was lots of trial and error, but I really learned a lot! The quality of my games has improved dramatically and now I can generally do what I set out to do in game development (assuming there is enough time and resources).


(Technically correct answer):

I have been doing game development for around ten years. I had no idea how to program when I started, so I decided to learn both programming and game development at the same time (I was young). I was motivated because I wanted to make amazing, AAA quality games (I had really unrealistic ideas of what a solo game developer could do at the time). I talked to a friend about it, and he suggested starting with Python and Pygame so I could learn both game development and programming at the same time.

I then started working on prototype and beginner games, that I never released, for most of the ten years. During that time I jumped programming languages several times, and tried a bunch of game engines. I followed lots of tutorials, took online courses on programming, and tried several game templates.

As I started entering game jams, I found out people might like playing games I make, and then I started taking game development seriously and tried learning as much as I could about the process by making a bunch of prototype games.


So yeah, I've been doing game development for four years, give or take a few months. :smile:


@MagicLord said: Not sure i got this issue on Unreal 4, it doesn't uses Bullet physics but Nvidia physX.

I only had the issue once in Unreal Engine, and I think I was using UDK at time, so it's probably been fixed by now. I was just testing UDK at the time, so I probably did something wrong with my code/setup and that's why I had the issue.

I know I've had this issue a few times in Unity, which also uses Nvidia physX. I would not be surprised if the bugs are fixed now, since the last time I used either Unity or Unreal was several months ago.

@MagicLord said: Not sure i got this issue on Unreal 4, it doesn't uses Bullet physics but Nvidia physX.

I only had the issue once in Unreal Engine, and I think I was using UDK at time, so it's probably been fixed by now. I was just testing UDK at the time, so I probably did something wrong with my code/setup and that's why I had the issue.

I know I've had this issue a few times in Unity, which also uses Nvidia physX. I would not be surprised if the bugs are fixed now, since the last time I used either Unity or Unreal was several months ago.

With Unity for a 2D or 3D game ? I got the issue only for a 2D game, 3D for 2.5D game was fine, but there was possible some work around in Unity adjusting some physics parameters.

Godot need to fix that issue for 3D.

lol,beginner of course not :p , its great that this forum have people with such vast experience.

I haven't looked at the project, but something sticks out to me with that line of code being used for the character.

By the looks of things, the game is going to be a top-down adventure using 3D models, but the fact you seem to be canceling out the gravity hints that the top down setup is based on the X/Y axis instead of the more sensible way of doing it on the X/Z axis (where the camera is pointed down instead of forwards).

If my assumption is correct, having it top-down based on the X/Z axis would have no visible difference to the player, and you wouldn't need to take gravity into account when he moves.

@MagicLord said: With Unity for a 2D or 3D game ?

3D, with box collides for the walls of my game. I probably just needed to look at the physics parameters though.

Godot need to fix that issue for 3D

Well, it’s more of a Bullet issue than a Godot one. Ideally somone would fix it in Bullet, and then Godot (Armory, and other game engines using Bullet) can just update and not have the problem anymore.

(Though we’re getting a little off topic :wink: )