Can't get character to walk straight

Wydlfire42

New member
Hello all,

I've only just started with UCC this week, so this is very probably something I'm missing. But... I've got a character with a Cinemachine FreeLook camera following her around. I've installed the UCC+Cinemachine integration according to the instructions, and double-checked several times. I'm actually not even SURE that Cinemachine is the problem here but...

Basically, I've hooked up the "ForwardMovement" parameter in my animator to play my "Walk" animation using Root Motion. I was using this previously with the Animator and a Rigidbody, so I know there's no rogue rotation in the animation. But when I use it with UCC, my character turns on a 45 degree arc to the left, even if the only input is "w" on the keyboard (so, it's not weird drift from an analog input). If I try to correct for the left drift, the camera starts spinning rather wildly.

I'm using Third Person Adventure, and I *think* that the problem is that UCC seems unaware of where the camera actually is, so it's constantly trying to correct the character's rotation, resulting in the camera repositioning and they basically fight.

Any tips on what to look for?
 
Ok, I've been fiddling with this a fair bit trying to figure it out. The initial angle that the Cinemachine camera chooses to look at my character is more or less from the front. I'm setting up a test scene so I didn't care about that yet, but I've discovered that if I press "Down" and more or less try to walk INTO the camera, it works reasonably well. So, I think that UCC is taking the initial camera position as the point of reference? Is that possible?
Also, am I supposed to let Cinemachine read inputs for camera rotation itself (which does work if I do) or is UCC supposed to be doing it? (Which, doesn't work)
 
More progress; if I enable "Recenter to Target Heading" so that Cinemachine moves the camera behind the character on its own (and I turn down the rotation speed a LOT), it becomes fairly usable to walk forward and turn with a gamepad. It still tends to go totally wonky with the keyboard and mouse though. And, I kinda don't want it to keep trying to force a behind view anyway.

I'm really floundering here, it there more guidance for getting this to work WELL with Cinemachine than just the basic steps here?
 
Have moved this thread to the Integrations section. I'm not familiar with Cinemachine unfortunately. A quick check, you don't have any other inputs connected, e.g. gamepads (even wirelessly)?
 
I do have an XBox controller, though it works better than the keyboard/mouse. As in, with "Recenter to Target Heading" checked as mentioned above I'm able to walk forward and steer alright with the left stick. Rotating the camera is still a mess though. I'm not clear on if I'm supposed to use Cinemachine's controls for this, or UCCs. UCC's don't seem to work/do anything at all, but Cinemachine's conflict with movement so...

The keyboard/mouse is much more difficult, and yes, even when the XBox controller is off/not connected.
 
It does sound like it could be controller related. The input manager doesn't handle controllers too well so have you tried the Input System integration?
 
I guess I didn't mention, I've been using the Input System and its integration the whole time (I have the old input system turned off in settings too). It doesn't feel controller related to me, but I guess I can't completely rule that out.

I've gotten a better handle on the exact mechanics of the problem though so I think I can offer a better description that might make the problem clearer. Let's leave the gamepad/controller totally out of it for simplicity because the base problem seems to be shared between it and the mouse. I've turned it off and it doesn't appear in the Input debug window.

- IF I have "Recenter to Target Heading" enabled on Cinemachine's Freelook Camera, AND I wait for the camera to be perfectly still behind me and *DO NOT TOUCH* the mouse at all - then "W" on the keyboard walks forward just fine. "A" and "D" *do* spin the camera in that direction and you can steer pretty well.
- However, if I manually turn the camera to look at her from the right (as an example, any angle is a problem) and press "W" and NOTHING ELSE, then she both walks forward AND spins to the left simultaneously, also spinning the camera (so the effect is that I'm always looking at her from the angle I started at while the room spins). The spinning will continue until I let go of the input, then the camera will find her back and at THAT point I can control her properly again.

- If I turn OFF "Recenter to target Heading" the main problem is that it's near impossible to find the "exactly centered on her back" position manually, so there's nearly always some "Spinning" going on. Which is why that setting seems to help so much, I think.

-It also becomes a problem when the camera has to go off-center/can't center behind her to avoid room geometry
 
Oh, in fact, I *think* the EXACT same code that's making the camera directly rotate when I press A and D manually is ALSO what's happening when the camera isn't directly behind her!

Like, camera is directly behind, you turn 45 degrees left, the camera is moved 45 degrees right so that it remains directly behind her. But if the camera is orbited 90 degrees to her right to start with and I try to walk forward, she turns 90 degrees left (to arrive at what would've been straight) but it ALSO turns the camera to the right another 90 degrees... repeat forever, and that's why it's spinning!

Is this something I've hooked up wrong or a bug?
 
I performed another experiment; if I disable the Cinemachine Brain, and switch the Camera Controller script from "Third Person Cinemachine" to "Third Person Adventure" then the controls work perfectly with both KB+Mouse and Xbox Controller. So, I think that really narrows the problem to the Cinemachine integration and rules out the Input System/input devices.
 
And now I've tried it with a Cinemachine Dolly cam and a few others. Worked fine - so this seems to ONLY be a problem with the Cinemachine Freelook camera.
 
Thanks for continuing to debug it.

With the free look camera are you in a traditional third person view or something different? If it's something different then I can see how the look direction could cause problems. I will add a parameter called Use Character Look Direction to the Cinemachine view type which allows you to not use the camera's rotation for the look direction. I'll upload that shortly.
 
Thanks for continuing to debug it.

With the free look camera are you in a traditional third person view or something different? If it's something different then I can see how the look direction could cause problems. I will add a parameter called Use Character Look Direction to the Cinemachine view type which allows you to not use the camera's rotation for the look direction. I'll upload that shortly.
Traditional third person.

I think I might've found the key though, after a LOT of fiddling with things;
1615586648280.png

This setting - when I set it to World Space, the camera works right! It had been set to "Lock to Target". I'm not sure this is a total solution because with "World Space", "Recenter to Target Heading" doesn't work right anymore. But I'm not clear - should UCC be working with the other setting here? What's correct?
 
Top