Cinemachine Free look camera with Aim position

Hi. My main idea is to make a very simple mechanic for picking up and throwing items.
I made a pretty solid free look camera with three rigs and a script for picking up objects.
Now, I want when mouse 1 is pressed and hold to activate “over the shoulder” or just a little zoom camera which will help me to aim easier.
I need the player to be able to aim with a crosshair and throw the item in that direction where the crosshair points.
Very similar to this - x.com
(Only the zoom and throw items, not the climb part)

I am using this script that gregoryl provided in another topic - using UnityEngine;public class ActivateOnKeypress : MonoBehaviour{ pu - Pastebin.com

I made a second camera, but now my main problem is that my “zoomed” camera does not correspond to the character inputs and does not rotate with the character so it’s impossible to try implement the throwing mechanic

Here is what I’ve done till now
https://vimeo.com/498422396

What will be the way to achieve something like this in the first video? Many thanks in advance! :slight_smile:

Basically, I found that this approach may be the right one for me. Unfortunately I am not able to integrate the solution for the aim camera in my script. I tried copying the methods and variables with no success. Can somebody help me with that? Thanks!

Yes, that is the solution I would have recommended. Have a look at the AimingRig sample scene that ships with Cinemachine. That might help with integration.

Hey Gregoryl. Thanks for the response! :slight_smile: I was trying to integrate the aimriggin from the sample scenes but with no success.

Here is what i’ve done until now - As u can see, I my main camera is ready to go, but after I zoom only the crosshair is moving, and the player is rotating with ‘w a s d’

https://vimeo.com/499299507

Here is my code. I don’t have idea what i’ve messed :smile:
https://hatebin.com/fprcwcappo

This is the script i’ve attached in my second camera. I know maybe it’s bad to put the commands in the camera change script but I am trying to make the things simpler instead of putting all this code in my character controller script.

It’s not clear to me from the video what it is that you don’t like. It seems that in zoom mode, the character is always facing away from the camera, looking at the reticle, and when you move the mouse the whole thing rotates. Is that not what you want?

Your code does indeed look strange to me. I think the correct paradigm is: mouse moves the character (not the camera), and camera tracks the character, always staying behind it in 3rdPerson mode. How do you rotate the character when not in boost mode?

My character does not rotates while I rotate the mouse. Only on ‘w a s d’. I need to be otherwise - The character to rotates when my “crosshair” moves and not on ‘w a s d’. Actually, in this video, my aim is not moving on the y axis, and only the inner circle of the crosshair is moved on x axis

I rotate my character with the “w a s d” when I am not in aim mode

So then in your script, make the mouse rotate the character, and not the invisible character child.

It seems to me that your character controller requires 2 modes: rotate-on-mouse mode, and rotate-on-wasd mode.

Hi Gregoryl! Thanks for the suggestion. I am still trying to make that but with no success so far :confused:
However, I’ve noticed a strange flickering on my character at the very end of my mouse position (just before my mouse stops) Do u have any idea what could it be?

Here is video of the weird flickering of the character, and here is my inspector settings:

https://vimeo.com/499553609

Hey. I am still have this problem with the strange character flickering. Do I need to open a new thread for that? Thanks! :slight_smile:

Yes, I see the little jump. You have the vcam set up with POV component responding to the mouse. Do you have any other scripts active that are also responding to the mouse movement? If so, can you disable them all and see if you still get the jump?

I literally tried to disable all gameobjects in my scene one by one but nothing fix the problem. Tried to disable the script attached to the zoom camera that is changing the priority but it is not that either.

Can you make a small repro project that shows this problem and send it to me?

EDIT: something else you can try before doing that. In both axes of the POV control, change the speed mode to “input value gain”. You’ll also have to lower the Speed value by a lot (something like 10X). Try that and see if the problem goes away.

6724981--773785--upload_2021-1-14_12-7-21.png

Hi. I tried this but it’s still the same. I write u on private message :slight_smile:

1 Like

Hey @Jairusx we found and fixed the bug. The fix will be available in the forthcoming CM 2.7.2. Thank you for your help with this issue!

2 Likes

Hey! Thank you very much for the support and fixing the bug!