I am facing a few problems with using BetterCharacterControl to control player’s character :
The first one is the isOnGround() method returning always true, even when in mid air with nothing under it.
I solved it by a raycast for now, is there a better way to do ? Because sometimes it don’t works, like when i’m standing in the edge of something so right under me is void.
The second one is that my character do a sort of “auto jump” when i run over a little step, like sidewalk’s one. when i climb stairs it’s even worse as i “fly” up and my head bump into the ceiling …
When i modify the gravity of the whole physics space (like setting it twice the earth’s value), it prevent this problem but it also affect other stuff, if i modifty only the player’s gravity, it don’t change anything.
Is there a way to tell that only the player should have stronger gravity ?
The last one is not a problem but a question : is it possible to apply a force or an impulse to the BetterCharacterControl player ? i have implemented explosive which trigger an explosion pushing objects apart, and i want to also push the player if he’s close enough to be affected, but i don’t see any method like that in the BetterCharacterControl.
its hard to tell without seeing code but might be you set unrealistic values for mass compared to the size, say calling its constructor with BetterCharacterControl(1f, 1f, 1f) means that person is only 1 meter tall, but 2 meters wide and only weights 1 kg, he is likly to float when running up stairs.
as to the impulse thing you might want to investigate into
since it should be exactly what youre trying to achieve
Walking applies a force. It’s functionality mimicks pushing a box along the floor. If you push it with enough force at a ramp it will behave just like your observations. For simple cases it’s fine, but in actual games you will need to create a more advanced model. There are only a few rare cases where you can just throw code together like that. In almost all cases you want a specific set up, unique to your game. Use it as a reference in making your own.
Walking is described as a series of controlled falls. The force is therefore more of an angle heading downward in addition to forward. Hence you don’t usually fly off or behave like you’re being pushed. I adjust my centre of gravity and gravity pulls me down, and it’s that act of controlled fall that moves me forward. You don’t slip along the ground like a conveyor belt. It would be more like a serrated edge of you were to plot it on a graph.
Instead of trying to replicate reality, pretend it’s fine to get pushed and deal with the corner cases appropriately.
Those are all problems with BCC, yes, at least number 2 and number 3. I don’t know about number 1, I never investigated that but shouldn’t it already do a raycast? Probably it uses a physics raycast and hence only casts against collision shapes.
2: I am having the same problem and trying to fix it, the problem is that if you set the gravity high, falling down from somewhere is unrealistically fast, so you might have to add some detection for falling “upwards” (e.g. motion is upwards but no jump button pressed) and then stop BCC from walking upwards.
3: is tightly closed together with 2: BCC removes all forces and impulses on it (it’s called dampening there, maybe you can also reduce the dampening?) and then just applies the walk force. So maybe it works if you set dampening to 0.8f
@pspeed Thanks, it was the reason why it wasn’t working : setting the gravity after adding to physics space solve the issue.
@Samwise i changed the weight (which was 1kg like in the tutorial) but it don’t change anything for that issue, it just change the force needed to jump and also the way you push other objects.
For the impulse, i already knew that as i’m already using it, but for the BetterCharacterControl, i didn’t had access to the rigidBody object to apply impulse on, for now i use the jump for that purpose (by modifying the jump force right before) but it look a bit dirty.
Thanks for all the answers, for now it’s not perfect but it’s better with the dual-gravity … I don’t search an ultra realistic movement, well not at the moment, i just want to achieve a regular FPS-like movement including jumping on or over things.
In a couple of the game physics books I read they said most games set gravity at 20… about twice earth. Their explanation is that in games everything feels too floaty otherwise.
I always wondered why this is but I figure it’s because game environments tend to be pretty grossly scaled up. I mean, when a small room is 10x10 meters and doors tend to be 2-3 meters wide… I can see needing to scale gravity up to makes things feel tight.
Edit: also add to that that most “walking speeds” are at slowest a good jog in real life… and running is crazy fast.