Hi, I am currently working on a game of which contains splitscreen levels, using two Xbox 360 Controllers.
I have all input working, as well as a working splitscreen layout, however, I am stuck with an issue of which one out of the two cameras set up doesn’t update the direction of the player properly, making it so that when focusing on the character on the screen with the issue, if you turned and moved, it would be inverted, but will uninvert in certain locations of the map and then back again.
I have looked into the code as I am using the default ThirdPersonController for both characters and I am currently using the SpringFollowCamera script too.
One thing I should point out is that if I change one of the two cameras’s tag from MainCamera to something else, the one of which is still the MainCamera works with no issue. This happens the other way around with the other character and camera.
Something that I thought was worth noticing is that in the script for the ThirdPersonController, there is a section about updating the character’s facing direction with the camera, and I have tried tweaking it with no luck, so I reverted it back to the way it was. Here it is:
function UpdateSmoothedMovementDirection ()
{
var cameraTransform = Camera.main.transform;
var grounded = IsGrounded();
// Forward vector relative to the camera along the x-z plane
var forward = cameraTransform.TransformDirection(Vector3.forward);
forward.y = 0;
forward = forward.normalized;
// Right vector relative to the camera
// Always orthogonal to the forward vector
var right = Vector3(forward.z, 0, -forward.x);
var v = Input.GetAxisRaw("updn");
var h = Input.GetAxisRaw("leftnr");
// Are we moving backwards or looking backwards
if (v < -0.2)
movingBack = false;
else
movingBack = true;
var wasMoving = isMoving;
isMoving = Mathf.Abs (h) > 0.1 || Mathf.Abs (v) > 0.1;
// Target direction relative to the camera
var targetDirection = h * right + v * forward;
// Grounded controls
if (grounded)
{
I am looking for somebody to help optimize this code so the one camera that is faulty is fixed, then I can finally move on and finish this feature.
Thank You very much for reading and I hope to get a reply as soon as possible, thanks.