winstxnhdw / lc-hax

A powerful, feature-rich and highly performant internal cheat for the co-op indie horror video game, Lethal Company.
77 stars 25 forks source link

[Bug]: Possession: Gravity and velocity fixes #331

Closed D1GQ closed 4 months ago

D1GQ commented 5 months ago

Just been taking a look at the code and it looks like when you pulled in the possession branch you reverted the gravity logic, I don't know if there were issues with my new logic but the problems with the old one is if you don't jump for a while then walk off a ledge your velocity still increases so you just teleport to the bottom, the new code prevents you from Gaining velocity while on ground and resets it. Also suggest adjusting the gravity a bit so it's a bit more less floaty and where you don't Glide when you're going downstairs.

Changes

Old:

        void ApplyGravity() {
            Vector3 motion = Vector3.zero;
            this.VelocityY -= gravity * Time.deltaTime;
            motion.y = this.VelocityY;
            _ = this.CharacterController.Move(motion * Time.deltaTime);
        }

New:

        // Gravity adjustments
        const float jumpForce = 9.2f;
        const float gravity = 18.0f;
        const float maxVelocityMagnitude = 15.0f;

        // New gravity logic
        void ApplyGravity() {
            if (CharacterController.isGrounded) {
                this.VelocityY = 0f;
            }
            else {
                this.VelocityY -= gravity * Time.deltaTime;
            }
            Vector3 motion = Vector3.zero;
            motion.y = this.VelocityY;
            _ = this.CharacterController.Move(motion * Time.deltaTime);
        }
winstxnhdw commented 5 months ago

I removed it because isGrounded actually doesn’t work here.

D1GQ commented 5 months ago

I removed it because isGrounded actually doesn’t work here.

Interesting this might be a dumb question but is there a reason why? I've tested myself and seems that it fixes the velocity issues.

winstxnhdw commented 5 months ago

It might be something else that fixed it but isGrounded is leftover Unity code that the developer never intended to implement so it is not trustworthy here. I’ve tested it before but I could be wrong. Does the issue of falling off the ledge still happen with my change? I didn’t find anything unusual in my testings.

D1GQ commented 5 months ago

It might be something else that fixed it but isGrounded is leftover Unity code that the developer never intended to implement so it is not trustworthy here. I’ve tested it before but I could be wrong. Does the issue of falling off the ledge still happen with my change? I didn’t find anything unusual in my testings.

I downloaded a fresh version of the branch and it was a issue, then I added that logic in it seems that it wasn't happening again, but it's also strange because I can't use the is grounded Logic on the jumping for some reason so your point makes sense, I don't know what's going on.

D1GQ commented 5 months ago

Let me test things further and I'll give you an answer.

winstxnhdw commented 5 months ago

Let me get back to you later. I am extremely fatigued.

D1GQ commented 5 months ago

Here whenever you can if you look at these videos the first video is from the main build so the normal code the second video is with my gravity logic, so I don't know what's going on.

Video 1 https://streamable.com/w0seyk

Video 2 https://streamable.com/nrm1hj

joep26020 commented 5 months ago

Here whenever you can if you look at these videos the first video is from the main build so the normal code the second video is with my gravity logic, so I don't know what's going on.

Video 1 https://streamable.com/w0seyk

Video 2 https://streamable.com/nrm1hj

interesting, i dont have those counters on the top right.

D1GQ commented 5 months ago

interesting, i dont have those counters on the top right.

That's LethalMenu, I use it to spawn monsters to test.

winstxnhdw commented 5 months ago

Here whenever you can if you look at these videos the first video is from the main build so the normal code the second video is with my gravity logic, so I don't know what's going on.

Video 1 https://streamable.com/w0seyk

Video 2 https://streamable.com/

Very strange. I think we should just cap the velocity then.

xAstroBoy commented 4 months ago

@winstxnhdw he's not wrong, isGrounded is a unity feature, you should use it here.

winstxnhdw commented 4 months ago

Try it out. It doesn't work sometimes.

xAstroBoy commented 4 months ago

Try it out. It doesn't work sometimes.

Actually it does , i tried it out, your logic makes the enemy slip thru the holes, while his doesn't.

winstxnhdw commented 4 months ago

Slip through holes? The logic is for prevent the enemy from jumping in the air.

xAstroBoy commented 4 months ago

Slip through holes? The logic is for prevent the enemy from jumping in the air.

Not just that, but as well not make it gravity suck the enemy into the hole, but just slowly fall into it.

winstxnhdw commented 4 months ago

Falling slowly is not realistic or what the mobs do in the game.

xAstroBoy commented 4 months ago

Falling slowly is not realistic or what the mobs do in the game.

but for sure they dont fall in the holes of the maps like a bowling ball... we cannot block this from happening but we can somewhat slow it down which @D1GQ is doing.

winstxnhdw commented 4 months ago

Have you seen an Eyeless Dog on Titan? They fall exactly like that when they chase you down the ladder.

xAstroBoy commented 4 months ago

Have you seen an Eyeless Dog on Titan? They fall exactly like that when they chase you down the ladder.

yes but not on the inside part, outside is way different.

winstxnhdw commented 4 months ago

Okay. I’ll add it back.

winstxnhdw commented 4 months ago

I've added this back.

winstxnhdw commented 4 months ago

Probably need to play around with the collision box's scale to prevent the ground clipping bug.