Hi, I have scripted a camera so that when the player is running by holding down the ‘w’ key he can also hold down the shift key so the camera looks directly behind him. However, this then affects the direction he is running in.
What can i do to avoid this?
I am reading that it is to do with the object and world space but I am not sure how to implement it?
Together with an offset, I am currently switching the camera view to look behind the player using:
You can try changing the CameraType to scriptable. This way, you can make the camera look backwards behind the character. But you also have to script the velocity of the camera moving in the direction of the character while its simultaneously looking backwards.
I’m not entirely sure what you mean by direction relative to a camera’s rotation, but I believe you’re trying to say that the camera still follows the player even when being changed to scriptable. However, changing the CameraType to scriptable causes the camera to stop being influenced by the internal camera scripts. The camera does not move nor rotate.
So are you guys in agreement that it cant be done simply? The only solution i can think of is to change the player’s directional velocity in relation to the camera angle but tbh for what it is worth, it is too much effort for such a minor feature.
One solution you can try is to make a rear camera using a viewport frame. I’m not entirely sure how this will work performance-wise but I guess its worth a shot.
Thanks Venom, the viewport route was how I originally started out but it was too resource intensive and so I hoped that i could solve it with a simple camera switch.
Are you looking to make the movement not relative to the camera? Then I believe you can overwrite the default control script through this custom control script:
Thank you for the idea dthecoolest though i couldn’t use it as it was mouse based. However,I have now sorted it myself by simply multiplying all my UserInputService variables by -1 whilst the rear camera button is pressed. Thanks to all for offering advice