SmoothShiftLock [Module]

I looked into it and it looks like criminality has its shiftlock in playermodule, but it doesn’t have a smooth transition to camera offset on enabled/disabled, only smooth character rotation. Combat warriors unlike criminality has disabled default shiftlock, and has a custom shiftlock.

2 Likes

Good to know that combat warriors went with a solution similar to yours. I think it would be a good idea to package your asset with a playermodule modified to have its shift lock code removed for better performance. Futhermore i think that you should look into implementing springs into your module for better motion.

4 Likes

That’s a good recommendation, I’ve got an idea of how I could add it to playermodule. I will look into it tomorrow.

2 Likes

I did not succeed with moving it to the playermodule, but I implemented spring.
Now it uses spring for shiftlock offset transitions, I did not add spring to character rotation because it looks weird and I think lerping works the best.

3 Likes

That honestly sucks that you were unable to add it to the player module. Also, thank you for adding spring for motion in the right places.

4 Likes

trying to toggle shiftlock using
module:ToogleShiftLock(true)
gives this error

6 Likes

Sorry for the late response, but I fixed it.
Update the module and try using module.ToggleShiftLock:Fire(boolean).

1 Like

also not a big problem but you spelt toggle wrong
image

4 Likes

Having an issue where I can no longer properly rotate the camera when I’m not in shiftlock.

Example (I’m trying to rotate camera):

1 Like

Inside of the Spring (CustomShiftLock>SmoothShiftLock>Utils>Spring) You want to scroll to the end of the Script to where you see this:

	return
		a0*p0 + a1*p1 + a2*v0,
	b0*p0 + b1*p1 + b2*v0
end

return Spring

Add an indent before the “b0p0 + b1p1 + b2*v0” part So it’s:

	return
		a0*p0 + a1*p1 + a2*v0,
		b0*p0 + b1*p1 + b2*v0
end

return Spring

That Should Fix the Situation

1 Like

Can you make it so that it works with chickynoid?

robloxapp-20230305-1159110.wmv (1.0 MB)

1 Like

Added an indent, however, it does not seem to have fixed the issue the behavior is still the same.

Edit: I’ve also tried to disable every other script within the project as well which didn’t fix it, I have also attempted to remove the “StarterCharacter” from the “StarterPlayer” but it had the same outcome.

In addition to the above I have attempted to do it in a completely different place with no scripts at all, it has the same behavior and I have also found out another bug with the system where if you scroll all the way into first person then the camera glitches whenever you walk around.

Video here: https://gyazo.com/fd06383581bf01e2413aba33e159aa27

4 Likes

My apologies, I wasn’t fully aware that the script had been updated. I had added the ShiftLockModule without testing it thoroughly and assumed that it would fix the issue. Upon checking the older version of the ShiftLockModule in my other game, it appears to be working fine until I add it to a new game. If I find a solution to the problem, I’ll be sure to update you.

1 Like

No worries, it’d be much appreciated if you could see if there’s a solution to fix this. If not I suppose I’ll wait until @Rixtys99 is available to fix the system themself.

2 Likes

I fixed the issue with camera not rotating while shift lock is off, but I’m still thinking about how to fix the bugging in first person. It occurs because I’m detecting when the player is in first person by calculating the distance between player’s head and the camera, so If your camera is far enough from the head, then it will start offsetting the camera and create that bugging effect. I tried requiring BaseCamera module and retrieving IsInFirstPerson() from it to check when player is in first person, but had no success. So if you know any better way to check when player is in first person then please let me know.

Edit: Fixed this bug too.

2 Likes

I don’t know, I don’t know a lot about that system and have never used it, but I’ll see if I can do anything.

1 Like

So it seems to work fine in studio, but after publishing and trying in game, enabling shift lock doesn’t do anything

2 Likes

Cons: This module does not respect auto-rotate property and it’s not compatible with other shiftlock mechanics

Solution: Fork playermodule, this will allow for compatibility + respects auto rotate.

2 Likes

when doing Player:LoadCharacter() the shiftlock bugs out

3 Likes

On character death, the shiftlock becomes snappy and will often over rotate or try to flick towards the new camera rotation, it’s more apparent when you lower the shiftlocks dampener and other settings, below are the settings I used, and even on default settings the problem still persists.

	["CHARACTER_SMOOTH_ROTATION"]   = false,                      --// If your character should rotate smoothly or not
	["CHARACTER_ROTATION_SPEED"]    = 8,                          --// How quickly character rotates smoothly
	["TRANSITION_SPRING_DAMPER"]    = 0.8,                        --// Camera transition spring damper, test it out to see what works for you
	["CAMERA_TRANSITION_IN_SPEED"]  = 10,                         --// How quickly locked camera moves to offset position
	["CAMERA_TRANSITION_OUT_SPEED"] = 14,                         --// How quickly locked camera moves back from offset position

here below you can see the adjustment in action, this camera behaviour doesn’t occur until after the player has died, I think it pertains to the spring or the lerp but I’m not entirely sure; sorry.

https://streamable.com/7f0iai

3 Likes