Hello,
I'm trying to figure out how to get these 2 to work:
1. When the player presses R to have the camera look backwards (-180degrees), to see what is coming behind the player.
2. When the player is holding "left alt", even though the player might be walking/running, to allow free look around with the camera with the mouse until left alt is released then it goes back to normal,
My current camera settings are:
Spin rotation locked, and always behind target checked on
Pitch rotation locked and fixed angle of 10
Thank you
Comments
I have PlayMaker detecting R key down and then setting a global bool to true "lookBack", running an action asset to check book if true switch to look back,
then when R is up, it sets bool to false and runs the action again checks and if false sets the camera back to the other one,
Is this a good way to achieve this?
Free-looking can be disabled via the Player: Constrain Action or via script. You could either use PM to run this as with #1, or do it with:
http://pasteall.org/953200/csharp
My current active camera is locked for spin and pitch, I tested it with the script and the player cannot look around,
Then I changed the camera settings to free, whether I hold down FreeAim linked key or not it still does not lock/unlock the looking around it remains to what it is,
Could you please clarify to me how to achieve this properly?
Is Lock cursor in screen's centre when game begins? checked in the Settings Manager?
However I changed all those settings to test
So I enabled the lock on center, then had to Setup Input: CursorHorizontal and CursorVertical, was not sure what to put them as to map them on the mouse? so I just put them in as T, G, Y, and H on the keyboad.
Then testing again, still could not FreeAim,
I am using Direct Mouse & Keyboard, tank controls
You also need to set your Movement method to First Person to make use of free-aiming - since that is a first-person camera behaviour. Otherwise, you will need to write a custom script that handles the camera movement.
While you get free-aiming to work, remove the custom script for the moment so that it doesn't interfere.
Thanks Chris. I got all that working,
However Perhaps what I am trying to achieve is a bit more complex than I thought,
The way I imagined it is retaining my current Top Down camera, then when the player pushes the "free look" button, that very camera can look around without moving the character (unless the player is moving via its controls) with the direct movement settings,
then when the player lets go of the Free Look button the camera resets to its locked rotation, pitch etc.
The effect I am attempting to achieve is that the player can look around without impacting the players movements as an example, player is running forward presses the Free Look button looks left/right/up/down while continuing to run forward.
You could potentially switch to a new GameCamera that has "Follow cursor?" checked when the button is pressed (and switch back after), but the behaviour of a camera's own behaviour changing on a keypress is not AC does. For complete control over a camera's behaviour, it may be best to have the whole camera be a custom script, which can be added on quite easily (see the "Custom cameras" Manual chapter).
You could parent such a Camera to an existing GameCamera so that it's position still follows that camera's control, with your own camera script just handling rotation.
I think I'm overseeing the power of your 3rd person camera,
I just noticed that there is an option for Input Axis and I changed it to the Mouse ones we setup earlier, and this actually made perfect sense to me finally (I was very confused using the same walking controls as the camera rot/pitch),
Now it actually works great and saves a lot of work for any custom scripts when you already have created such amazing ones, especially since I do not have that talent,
What I need help with to achieve this by script is:
if (Input.GetButtonDown ("FreeAim"))
{
// old code KickStarter.playerInput.SetFreeAimLock (false);
// set the current active camera to Limited Pitch / Spin
}
else if (Input.GetButtonUp ("FreeAim"))
{
// locked
To call upon your current active camera via script and set it to Limited when FreeAim is down and then set back to locked when not.
Sorry for any confusion, I will have all the details upfront going forward when help is needed
The Scripting Guide details all public variables and functions that can be manipulated / invoked via custom script. In the case of the third-person camera's spin and pitch rotation locks, their entries are here:
spinLock
pitchLock
You can amend these by exposing a variable reference to your camera, and assigning it in the Inspector:
http://pasteall.org/958072/csharp
Quick help needed on this one, how do I always attach / get the current Active Game Camera?
As sometimes the player may be looking backwards etc, so I want to ensure the spin/pitch Locks enabled on the current active one rather than the one I attach
From the scripting Guide it looks like
However I think that is not the active game camera?
AC.KickStarter.mainCamera.attachedCamera
However, since you need to access properties of the GameCameraThirdPerson (which is a subclass), you'll also need to cast it:
GameCameraThirdPerson tpCam = KickStrter.mainCamera.attachedGamera as GameCameraThirdPerson;
Since it is just me working on my game release, I promise to credit where it is due especially with your asset and the phenomenal support you provide throughout.
thirdPersonCamera.spinLock = RotationLock.Free;
}