Stair climbing problem in 3d (closed)

My 3d model involves a lot of stair climbing. To make my life easier, the character has 2 collision objects. A kinematic one for movement on the floors and a dynamic one that I enable for climbing the stairs.
In the rooms there are paintings that I detect with ray casting. Once an image is detected, an animation starts that moves the player in front of the painting.
This animation seems to lead to an interesting problem that I failed to solve and so need I to ask for your help:
sooner or later (and this can take quite a bit), the dynamic collision object falls asleep and the character needs to bump several times into the stairs or hit them at high speed. I tried physics.wakeup(), this just seems to delay the nodding off by a bit. If I disable the animation, this problem does not occur.

Have you tried using raycasts?

1 Like

I wasn’t able to find a physics sleep problem and the raycast clicking then camera animation to the painting seems fine. Though, I think I did find the stairs issue you are talking about.

To recreate the issue I turned on physics debug in the project settings and in the main.script I changed the local speed_keys to 0.02 to slow the camera movement. I then approach the stairs right before colliding with them, face the camera straight down to look toward the floor and slowly move into the stairs with small taps of the forward key (“W”) until I see the collision arrow pointing in the opposite direction and get a small bump from the collision. The first staircase in the spawn room is fine. I then move to the next set of stairs and do the same thing , bump into the base of the stairs see the feedback collision arrow and release the forward movement key. Then I go to move up the stairs and I get the collision bumping you are talking about trying to go up the stairs.

So I take a look at the scene where the stair colliders are and make sure the slope isn’t to steep and check if there would be some kind of strange collision happening, they seem fine. So next I check the positions of the go’s and collision shapes and noticed that you applied specific positions for each of the collision shapes in your project. I’ve had a similar issue before and I know that sometimes the bullet physics engine( Defold uses for 3D physics) can be a little finicky when positioning and rotating away from the game object it belongs to. To solve my issue I had a GO for each collision shape and positioned and rotated the GO’s instead of the collision shapes themselves. In this case I changed the Y position of the floor2 box collision shape from 1.1 to 1.0 and that was enough to solve the issue. The stairs no longer produced that collision bumping .

For the doggo I have no idea :smiley: Is the dog a mix?

3 Likes

@MasterMind, @Pkeod , thank you both for your valuable suggestions.
@MasterMind, once more you took your time and dissected my testbed. Thanks a lot for this!
I think you found the root of the issue, the position of the shapes is the problem. This would also explain why the problem seems to occur on my upper floors. I am going to have a careful look at my collection again and rearrange the lot.
@Pkeod, I will also make a version that uses ray casting, you can never have enough tools in you arsenal.

I just did some tests:
when moving the shapes into their own go and positioning the go instead of the shape I still couldn’t climb the stairs after a while. But lowering the floor collision shape a bit seems to do the trick. There is a little bump now when the char lands on the floor because the top of the stair is now slightly higher. But still better than being unable to climb at all.

1 Like

Can #6576 be related? It’s about physics.wakeup() that will be fixed in the future release 1.3.3.

I also faced with falling asleep problems without a way to wake up the body by the code.

2 Likes

Hello @astrochili,

I had found your thread and wondered too if my issue might be related to your observations.

Nice. ah yes you could lower the other stair and doorway flooring to match the changes. You may need to find other issue areas and apply the same things.

1 Like

By the way, I’m working on a kinematic character controller. If you really want to use a kinematic controller instead of a dynamic one, I think it might be useful for you. I hope to have it ready for publication within a week or two.

9 Likes

Now, that’s an idea!

Issues, I never run out of them. Just found a bug in my animation as well :laughing:

3 Likes

That looks brilliant, lovely movement! Thank you, can’t wait to try it out.

1 Like

Is it clicking on image from the stairs? I see that it can position the camera height lower than the painting sometimes.

1 Like

Aha, that I never noticed. But I just got a rotation full circle and the camera rotating down to look at the floor when clicking on one of the images on a long wall while standing on the floor. A very rare kind of bug, never had it before and I have clicked, clicked, clicked on images very often now :grinning_face_with_smiling_eyes:

Just checked, you are right, clicking on an image while standing on the stairs does not work as intended. Thanks a lot for finding this!

1 Like

Last update:

I have meanwhile made a version that uses a kinematic collision object only which so far works fine for getting my char up and down the stairs.
All the problems I have either stem from:
the ray casting to find the image: each cast raises the character by a tiny amount and so eventually there is no more collision with the floor. If I reset the position, he cannot climb any more.
the rotational element in the animation: this sometimes messes with the enabling of the dynamic collision object.
I have also prototyped a splash screen. Now, when the game loads, the char spawns at a wrong position or drifts off to somewhere.

I ran out of ideas now and admit defeat. Surely, my players are clever enough to try again should they be stuck at foot of a stair. :grinning:
I remove the testbed, I don’t want anyone to use hopelessly buggy code.
And thus I close the thread.

1 Like

The very last update for those interested:
The combo kinematic (enabled for floors)/dynamic(enabled for stair climbing) that had sometimes failed seems to work now:
I simply changed the size of the dynamic collision shape from slightly larger to much larger, it’s twice the size now.
No idea why this seems to do the trick, but, fingers crossed, after 15 minutes of ascending and descending, so far I haven’t been stuck at the foot of a stair. I am so happy :smiley:

2 Likes