Hello, I’d like to create a situation in which I can force the player to face a direction regardless of their attempts to change their face direction with shift-lock/first person.
This does not mean they cannot look around, just for a brief moment, the player will face forward, or to the side, and any camera movement cannot override that.
The issue is every time I look online instead of finding a way to force a player’s facing direction, I instead find someone asking to force a player to face a direction and is often misinterpreted and given a solution on how to “freeze the player” altogether. In other words, the solutions would describe simple answers such as anchoring limbs, but I want not only the player able to move, but to be able to move their arms in certain motions (i guess animations? I’ve never tried animations while the player is anchored but I’m pretty sure it won’t work. Anyway, that’s not even the problem.)
Someone, please tell me or at least point me in the right direction, I would appreciate it, because I don’t know where to start.
When we talk about look direction and stuff we are actually talking about a vector which is a offset of the player which updates from the players rotation. What we can do is get our direction component then make our players waist rotation matrix be perpendicular with its vector. We basically get the delta difference between them (see quaternions)
This is what I used to make this, but your character still moves in the direction of your camera, and no, rotating the character doesn’t change what direction you move in. Here’s the source code. Shiftlook.lua (670 Bytes)
Its been a while I don’t know if you found out yourself. You can set the cframe of the root part to the cframe of the camera. So wherever the camera looks the character will snap to the direction of the camera. But its pretty snappy so i recommend playing around with lerp function or even tweening if that’s possible.
I think I did use CFrame, but now that you mention it, lerping sounds like it might work better. I haven’t had problems with CFrame, but I’m sure it will become problematic at some point.