StateDriven Camera

While moving and switching between target and freelook
the camera will just go crazy for 1 sec and then go to the freelook
how can we blend it right so we prevent this behavior ?

Hi Babi6k,

I’m not sure if i have been in contact with you on Udemy about this but some people have noticed an issue which i havent been able to recreate.
I have been trying to get a video or a more recently a copy of the project to recreate the issue but i as its becoming a pinch point i will escalate it to Nathan as well.

@Nathan_Farrer

I dont have the course in udemy only here in gamedev.tv site
i bought it with the bundle for support as i had all the rest of courses of the rpg already

the problem happens in nathan videos also
lets say you are moving and running while on target camera
your rotation is different then in free look

then what happens with the camera it try to rearrange quickly to your position
and just go fast instead of smooth transition

so my question is how can we prevent this
as we move between states we have no control on the camera specifically with cinemachine as its brain controls the main camera

i tried in many way to prevent it
for now what i did is use inheirt position in the cinemachine virtual camera to have some kind of blend movement
it moves ok when character isnt moving but if it moves
or in my case i added a roll animation then it just go crazy when switching between cameras

i think probably the best way to fix it will be to create a camera script that control the camera rotation
but then im asking why to use then cinemachine anyway ?

also if you want a video i can make something later this evening and post

hey @babi6k - Post your Cinemacine Settings from both cameras (body/aim/etc), and scene hierarchy (to see how you set this up). It would also help to post a video showcasing your issue to better understand what the problem is. Regarding the rotation issue (ex: if the target is behind you and you want to target it . the camera will do 180 rotation) it will be fixed in a future lecture.
Regarding the Roll issue - its just a guess … but you are using Root Motion in your animations , or you baked the values in your animations . To test this issue : in play mode - select the player prefab (so you can see your capsule colider ) > press Roll > if your character is rolling OUT of the capsule colider … you have the roll baked in the animation > Fix : un select the baked position in your animation settings untill your character will roll WITH the capsule collider.

I didn’t do anything special to my cameras and they worked perfectly. Here are my settings. The only things I added from the course settings were increased damping on my freelook camera - default is 1 > I set it to 3.

you can see it in action here




i will show it later
but your not moving full circle with the object move full circle with the object and then switch to freelook when you behind him

the camera will go for 1 sec crazy and go back

about the rolling yeah i use root motion and have OnAnimatorMove to handle that

i need also to handle the rolling when in targetmode as it has different rotation
but need to change only the camera with the rolling

the collider stay with the player

Nathan has managed to reproduce a couple of issues with targetting and the camera and will be adding a patch to the Combat Polish video later on in the course.
If that video has been published already it may take a day or two for it to update.

Apologies for the inconvenience and i am interested to see the reproduction steps Nathan took as i couldn’t do that myself

Did you finish this video yet? Improved Targeting Selection | GameDev.tv . It fixes the issues you mention

yes i did
and now i just did a small demo very fast at my work latptop to show you the different stuff

Scene Heirchy

Follow Camera FreeLook



Target Camera

TargetGroup

StateDrivenCamera

Video for showing the problem

Thanks for the video and screenshots. I did a test with the target BEHIND me and the camera works as it should, Yes it will do a 180, but it looks fine on my end. I see you have some different settings on the FreeLook Camera Orbit and Damping. I tested those settings and it made the player be too close to my camera, creating a bad transition from Free look to Targeting . Maybe you can tweak those settings. Here is a screeshot comparing them (left are mine , right are yours)

Heres a video with how the transition works on my end

I might be wrong about this but In the video you posted it seems you might have some issues with your targeting script - when you enter targeting mode > the camera will focus on the middle of the screen not on the actual target. Maybe this is caused because you have 3 targets really close to each other.

Heres a video comparing those 2 settings i mentioned

We drop those dampening settings to 0 i think later in the course and adjust some others.
I’m reviewing the updated video atm

thanks a lot i will check it when i get back home , too much stuff at work
and my project is actually there
here i have some old version i just did 5 min a short setup to reproduce the bug to show you

also about 3 targets close to each other
even in the game while playing normally with enemies you will have situations with 3 targets close to each other so need to deal with it
it not supposed to effect it

Ok so i tested it out and its the same as yours i dont want that it switches like that i want when you change from target camera to free look it will continue where it left out as in free look if you want you can move your mouse and adjust yourself

the whole target seems weird even with your video now that i am looking

Just to let you know i used the same settings as yours i dont want the flip when moving between cameras

i want a camera same as you have in normal games you do target mode you move there you switch you move a little back thats it
or stay same position and move your joystick mouse

also try to run in a circle around the target and exit target mode see what happens

im putting here a video as i do step by step with nathan to have same stuff just different model thats it

Hmm, this isn’t really a course issue. The FreeLook Camera works exactly as you described it. If you want it to work in a different way, feel free to change the Orbit and Aim settings however you want.

I would suggest you start changing the orbit on your FreeLook Camera to “Lock To Target with World Up” and see if that’s more to your liking. I would also suggest you change the Yaw Damping on your Targeting Camera to 5-10. Cinemachine is a powerful camera system with tons of customizations that you can tweak to get the camera setup you want.


Based on your video I think you have some Aim issues with your targeting camera - the target and player are NOT in the middle of your screen as you move left and right. Did you change those settings?

You can test your camera settings by pressing the SOLO button and selecting the body/aim tab

Hope this helps.

I didnt touch the the settings of move left and right

the yaw damping help a little bit but its still not what i am talking about
also if you change to free look with lock to target
then the player walks not on a straight line

if you do inehirit position with the damping its a little more of my liking but still not the way it is
have sometimes that you move in a circle around the target and exit target mode which he acts weird

what i want is when ever you exit the target mode it will stay on the target same as it was on the target not go away or something the direction of the camera should stay the same

or it zoom out a little thats about it

and this is the same you have in all major games

Edited :
so i managed to make it work a little bit with a different virtual camera not the target group
thinking if to make a script for it but this is looking much better then before

1 Like

Hey @babi6k - I’ve made a new post about how to reset the FreeLook Camera and keep the same Position as you had in AtatckState . I think this is what you were looking to achive.

Hi@mihaivladan , would you mind telling me where you downloaded the animation that the character uses in your video. It looks really smooth. I’m looking for this kind of animation. I would appreciate it if you could tell me the download address of this animation.

Which one are you referring to? The walk/run animation are from this pack

https://assetstore.unity.com/packages/3d/animations/powerful-sword-pack-great-sword-katana-

That’s what I was referring to, many thanks for your help!

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms