Hello!
I quickly finished migrating my physics code to the new controllers the other day and I was playing with a type of ladders object for my character to interact with. Things have gone smoothly except for one glaring issue that I think I should probably handle or the player might go “WTF can’t I grab ladders in midair” ~ Well, that’s not exactly true, but the player can’t grab ladders by jumping at them. I had to disable this because I set gravity to zero while the player is ‘connected’ to the ladder to move along it. If jump-grabs are allowed, the problem occurs if I allow the player to jump to a ladder and grab it, they’ll simply float away because the gravity was set to zero mid-jump.
Is there a way I can cancel the upward momentum of the jump when the player interacts with my ladder? I noticed that the walkDirection was independent of this, so I’m a bit stumped.
Oh, and I love the changes to the physics using controls. It just feels more natural to handle the objects this way!
Thanks!
~FlaH
Maybe you rather want to not use a character but a kinematic node while on the ladder, the physics system allows adding both controls to the character and enabling/disabling them.
Oh interesting. Okay, I’ll give that a try here in a bit. Might take a while for me to get it right though.
One thing though that comes to mind; when I switch from coming off the ladder, disabling the kinematic control and enabling the character control again, will the character control try to resume the jump() that was issued back when the player jumped on the ladder? Here’s hoping not
Thanks!
~FlaH
Dont know, it shouldn’t when you place it on the floor.
Hello again,
I just got it setup to where I swap nodes when on a ladder. However, on this first pass, my fear was realized; the characterControl DOES continue where the jump left off when re-enabled and the kinematicControl is disabled (swap when getting off the ladder). It’s pretty unimportant when the player grabs the ladder on the downward part of the jump, because that’s unlikely to be noticed when dismounting it, but if caught on the upward part of the jump… Yeah… That’s sorta funny
Not sure how to proceed now. I may have to limit ladder grabbing to only being on solid ground, but I sorta don’t want that
EDIT: Well, I did think of something, though I’m not sure if it’s a good idea. I’m thinking about re-creating the characterControl on disconnection with the ladder. It doesn’t ‘feel right’ to do it this way though…
Thanks!
~FlaH
Are you sure you disable it and not remove it? When enabling the location of the spatial is set on the control, so it should work.
Site sorta died there for a few hours o_o!
Anyway, I figured out a solution to my problem. I took my old halfass characterControl and did everything there as before. BUT! Along with setting the gravity to zero, I set the jumpSpeed and the fallSpeed to zero as well, while on the ladder. As soon as the ladder is released, these 3 attributes are re-instated.
It feels a little cludgy, but it works like a charm. No problems at all with the interaction now. Marking thread as solved in a moment.
Thanks!
~FlaH
EDIT: Man, ninja posted in there as soon as the site was up eh Normen?
Yeah, I started the player off with the characterControl enabled, and the rigidBodyControl.setEnabled(false), and set to kinematic. On a ladder interaction and all the crap that goes along with seeing if you can actually get on the ladder, I was swapping the two via characterControl.setEnabled(false), rigidBodyControl.setEnable(true) (of course using their real variable names, doing it this way for clarity). And if the player escapes the ladder or explicitly wants off, I swap the two again. ~ But as I said, it resumed any previous jump data, which would allow weird abilities like being able to jump right before getting on a ladder, and resuming the jump on a ladder escape. It resumed the jump perfectly too, exactly when the swap happened.
I was never detaching any of these controllers in the process. I was always working with the same two I created on the player’s initialization.
It sounds like a nice project that you are working on. May I have a screenshot?
Hello again!
Eh sorry @WASD, the way I work is to get things actually functioning before prettying it up. Right now it just looks like a bunch of boxes… Because it is! It’s the dawning of the survival box-horror genre!.. Yeah… I couldn’t fool myself with that one.
Here you go.
Standing around:
“Ladder” (lol) selected. The capture hid my mouse cursor for some reason.
On the ladder.
The wiresphere around the player box is the player’s “touch” radius. Is determines if the player is even within reach of an object to interact with. I took it a bit further with some math and made it so that the player can only interact with things in the front half of the sphere as well, though it’s very difficult to see that from screenshots. The red box is just my most simple debugBox that’s interactive, but all it does is highlight and spout out syso’s when you click it. The whole thing is still pretty simple stuff, nothing ground breaking.
EDIT: Oh, haha. I noticed the fps was 24. I’ve got it capped right now because I’m trying to figure out a bug in my movement code that causes some tpf dependency issues. It runs around 1600 fps uncapped on my machine (though I usually cap it at 200 so I don’t burn up my video card).
Cheers!
~FlaH