Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How do I teleport a Cinemachine Freelook Camera without it lerping

Discussion in 'Cinemachine' started by technicalfiction, Dec 6, 2017.

  1. technicalfiction

    technicalfiction

    Joined:
    Jan 31, 2014
    Posts:
    12
    I have a section of my game where I teleport the character across the map without warning.

    It uses a freelook camera and cinemachine brain. On teleport, I move the player to a new position and try to move the camera to the right position, but it insists on overriding my set transform.position call and lerps over to where it should be very quickly, effectively turning what I want to be a hard cut into an unwanted instant lerp. Do you have any idea how I can fix this? I dont think swapping between two freelook cameras is a good idea, and it seems like it is always going to try to lerp if it is displaced.

    Thanks,

    Pablo
     
    Niter88 and DChap like this.
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Disabling then re-enabling the vcam after teleporting the target will snap it to the new position.
     
    SirGhoul and wlwl2 like this.
  3. technicalfiction

    technicalfiction

    Joined:
    Jan 31, 2014
    Posts:
    12
    Alright, I tried that in an earlier version and it did not work, it seemed to cache some positions. But I will update and try again.

    Thank you.
     
  4. technicalfiction

    technicalfiction

    Joined:
    Jan 31, 2014
    Posts:
    12
    Unfortunately, what happens is that when you re-enable the vcam, it does at first snap to the position but then immediately after interpolates from the old position to the where it should be - in my case flying through a bunch of a level objects along the way.

    It seems that if I could empty the cache of where it thinks it was last that would do the trick. Any ideas?

    Thanks,

    Pablo
     
    MaxLohMusic likes this.
  5. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    What about changing Default Blend in the CM brain to Cut?
     
    cuttinged likes this.
  6. technicalfiction

    technicalfiction

    Joined:
    Jan 31, 2014
    Posts:
    12
    Re-enabling the brain
    I am not switching cameras - I am turning a FreeLook and a Brain on and off. Switching to Cut has no effect. Thanks for the suggestion though.
     
    wlwl2 likes this.
  7. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    I've just tried re-enabling my FreeLook, Brain and there is no lerping, just cut.

    Which Cinemachine version are you using?

    (Also could you file a repo project?)
     
  8. technicalfiction

    technicalfiction

    Joined:
    Jan 31, 2014
    Posts:
    12
    Version 2.1.10

    Did you translate your target as well as your freelook by the same amount in between your enable/disable?

    (Also could you file a repo project?) what do you mean by this? I unfortunately cannot share this project.
     
  9. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    Yeah I've changed my transform position after disabling CM Brain and enabling it again.
    Repo project is just an empty project which shows the bug.
     
  10. technicalfiction

    technicalfiction

    Joined:
    Jan 31, 2014
    Posts:
    12
    Ok I am at work for the day but when I get home I will try to file a repo project.
     
  11. technicalfiction

    technicalfiction

    Joined:
    Jan 31, 2014
    Posts:
    12
    Are there any other notable settings that you are using on your camera to have a clean cut across world space?
     
  12. shedworksdigital

    shedworksdigital

    Joined:
    Nov 7, 2016
    Posts:
    40
    I've been trying to get this working today and have had some success. Rather than disabling/enabling the vcam component, you need to set its GameObject Inactive/Active. It's not longer lerping all the way across the scene, but there is a little judder when I set the new position. It also goes totally wild if I try and do this in the middle of a camera blend so it's not really a proper solution.
     
  13. technicalfiction

    technicalfiction

    Joined:
    Jan 31, 2014
    Posts:
    12
    ah thanks. Yeah, I realized that my prob may be associated with the fact that I am on 2017 2.0b8 but once I upgrade I will check again.
     
  14. spakment

    spakment

    Joined:
    Dec 19, 2017
    Posts:
    96
    Goreduc, nkholski, Racines and 4 others like this.
  15. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    That one does teleport following of the camera, but doesn't warp the aim component, e.g. Group Composer.

    Does anyone know how to adjust the Group Composer, so it would look towards the look at transform after teleportation? Calling OnTargetObjectWarped manually on the Group Composer doesn't seem to work.
     
  16. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    OnTargetObjectWarped will only correct the position. It is assumed that the aim will remain the same. Are you not warping all the group members? If you are, then the aim staying the same should work.
     
  17. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Yeah, this is a problem that aim stays the same instead of looking to the look at object.
    I guess altering rotation of the vcam directly should work. Need to try that.
     
  18. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Are you not warping all the group members?
     
  19. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Nope, just the virtual camera.

    Setting rotation directly didn't worked either.
     
  20. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Okay, so I've figured out this works perfectly (resets both position and rotation correctly for me):
    Code (CSharp):
    1.         private void TeleportCamera() {
    2.             _virtualCamera.Follow = null;
    3.             _virtualCamera.LookAt = null;
    4.        
    5.             StartCoroutine(UpdateCameraFrameLater());
    6.         }
    7.  
    8.         private IEnumerator UpdateCameraFrameLater() {
    9.             yield return null;
    10.        
    11.             _virtualCamera.Follow = *yourTargetToFollow*;
    12.             _virtualCamera.LookAt = *yourLookAtTarget*;
    13.         }
    Shame it requires a small coroutine alloc, but its better than non-working teleportation.
     
    IgorAherne and Fressbrett like this.
  21. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Glad you got it sorted out. Just for clarity, if you teleport the camera position while asking the camera to look at something, you shouldn't be surprised if the camera keeps looking at that something from its new position.
     
    trombonaut likes this.
  22. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Well, that something's position is the thing that has changed.
    And the camera is being teleported to that position no problems via OnTargetObjectWarped.

    Its the rotation that is kept the same which cannot be "warped" because that method doesn't exist.

    It would be nice to have some kind of API to force update position and rotation in a "cut" manner instead of relying upon workarounds that might stop working in a future versions.


    Because to be honest - OnTargetObjectWarped is terrible from the user / other programmer's perspective.
    Calculating delta direction / distance vector just to snap camera to its new position, really?

    Something is happening upon = null / = newTarget. That something could be put into that sweet "teleport" or "snap" method.

    If there's a certain technical limitation why it doesn't exist, or why its done that way, it would be nice to know it.
    Probably worth putting into docs.

    Just my 2 cents.
     
    Last edited: Sep 25, 2019
    halley likes this.
  23. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Maybe I'm not understanding your setup.

    Here is what I understand:
    1. vcam is following targetA, and looking at groupB.
    2. targetA gets warped, and you call vcam.OnTargetObjectWarped() to inform the vcam that the thing got warped and that it should not do a damped follow, as it would if targetA just moved very quickly
    3. groupB (and all the objects it contains) remains where it was before
    4. Result: vcam position warps correctly, but it continues to look at groupB, you can't give it a new rotation
    Is that accurate?
     
  24. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    1. vcam is following targetA, looking at targetA;
    2. targetA gets warped and I'm calling vcam.OnTargetObjectWarped();
    3. There's no group B.
    4. As a result: position warps correctly, but the rotation is kept the same, leading to the slow vcam rotation (due to damping) from the previous rotation towards new position of the targetA.

    Edit: I'll post screenshot of the setup tomorrow, if that would be helpful.
     
    Last edited: Sep 25, 2019
  25. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Ah, ok. I was misled by this:
    I'm still a little unclear on what exactly is going on, because of your point 4. OnTargetObjectWarped() will preserve the vcam-to-target spatial relationship, so I don't really understand why any rotation is needed.

    Can you show me a picture of your vcam inspector? I should have asked you to do that in the first place.

    Also: what parameter are you passing to OnTargetObjectWarped()?
     
  26. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
  27. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Already tried that, it didn't catch up if done in a single frame. The only workaround that worked out for me is the one posted above.

    Here's a vcam setup:
    upload_2019-9-26_11-20-18.png

    I'm pretty sure extra damping / rotation is caused by Tracked Object Offset property.
     
  28. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    ok, I understand now. When you teleport the target you also rotate it, and your binding mode is LockToTarget, so the vcam will have to change position/orientation because the offset is in target-local space. OnTargetObjectWarped() won't do the job for you because, as you pointed out, it only handles a change of position, not a change of rotation.

    Yes, disabling the vcam and re-enabling the same frame won't work, because the vcam's OnEnable() method won't get called until the next frame. Sorry, I didn't think of that in my previous post. Try instead to reset the vcam by setting vcam.PreviousStateIsValid = false. That should make the vcam snap to the new spot.
     
    GBudee, zg73, daxiongmao and 3 others like this.
  29. awiebe

    awiebe

    Joined:
    Oct 16, 2018
    Posts:
    14
    I've tried these steps and it doesn't seem to have correctly updated the rotation of the virtual camera. I am using the prebuilt rig which comes with the 3d platformer kit.

    I have augmented it with two scripts:
    • MainVCam: A singleton that allows me to broadcast information to the actual main virtual camera.
    • PortalTrigger: Causes my camera to be repositioned and rotated... or at lest it should

    Code (CSharp):
    1. public class MainVCam : MonoBehaviour
    2. {
    3.     public static MainVCam singleton;
    4.     public Cinemachine.CinemachineFreeLook[] cams;
    5.  
    6.     public Vector3 position { get; internal set; }
    7.     public Quaternion rotation { get; internal set; }
    8.  
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.         singleton = this;
    13.     }
    14.  
    15.     public void Invalidate()
    16.     {
    17.         foreach (Cinemachine.CinemachineFreeLook c in cams)
    18.         {
    19.             c.gameObject.SetActive(false);
    20.             c.PreviousStateIsValid = false;
    21.             c.transform.position = position;
    22.             c.transform.rotation = rotation;
    23.             c.gameObject.SetActive(true);
    24.         }
    25.         Debug.Break();
    26.  
    27.  
    28.     }
    29. }
    Code (CSharp):
    1. public class PortalTrigger : MonoBehaviour
    2. {
    3.     public Camera camera;
    4.  
    5.     void OnTriggerEnter(Collider other)
    6.     {
    7.  
    8.         if (other.tag == "Player")
    9.         {
    10.             //MainVCam.singleton.gameObject.SetActive(false); //doesn't seem to work
    11.             Transform playert = other.transform;
    12.             Transform l_cam = Camera.main.transform;
    13.             Transform oldParent = playert.parent;
    14.  
    15.             //Move the player in relation to the camera rendering the portal so the transition is seamless
    16.             //Rotate the player so they are facing towards the same direction as the camera rendering the portal  
    17.             //so they are correctly oriented camera relative when they arrive.
    18.             Vector3 relpos = l_cam.InverseTransformPoint(playert.position);
    19.             playert.position = camera.transform.TransformPoint(relpos);
    20.             playert.rotation = Quaternion.LookRotation(camera.transform.forward, Vector3.up);
    21.  
    22.             //Update vcams
    23.             MainVCam.singleton.position = camera.transform.position;
    24.             //Orient the camera to face the same way as the camera that rendered the portal
    25.             //This is the part that doesn't work
    26.             MainVCam.singleton.rotation = camera.transform.rotation;
    27.             MainVCam.singleton.Invalidate();
    28.             //MainVCam.singleton.gameObject.SetActive(true);
    29.         }
    30.     }
    31. }
    Conversely if I just turn off the virtual cameras and reposition the main camera directly it pops right into the correct position. Then as soon as I turn the virtual cameras back on it is at the correct position, but the orientation screws up, as if it did not invalidate the orientation.
     
    Last edited: Jan 3, 2020
  30. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    @awiebe You are using FreeLook vcams, which have the added complexity of axis values, which don't get repositioned automatically by default. My guess is that the axis values are not set appropriately after the position warp. Try setting them to 0 and placing the freeLook appropriately so that this value makes sense. I don't know how you've set up your FreeLook so I can't give any more details.

    Maybe also this might help: https://forum.unity.com/threads/setting-direction-for-freelook-camera.802497/#post-5343048
     
  31. awiebe

    awiebe

    Joined:
    Oct 16, 2018
    Posts:
    14
    It is using the classic input system's mouse movement, which returns the delta of the mouse.(The 3DGamekit Lite calls this axis CameraX and CameraY respectively. If the mouse is stationary there is no input, therefore passing through the portal with the mouse neutral the axis are zeroed.

    As I understand it this means that the inputs to cinemachine are zero.

    The camera also appears to be facing the exact direction and is in the same position relative to the lookat as before I teleported the lookat position.

    Symptomatically it is appears more like the new position and orientation were not considered when resuming the camera. Since the main camera simply copies the transform of the destination camera, and then the player is transformed relative to the main camera to match the same relative position, it seems to me that when the freelook cam is re-enabled cinemachine should evaluate the shot, see that it is in a valid position and get on with its day, that is unless manually relocating this camera in some way breaks the virtual camera's state.

    It is as if when the target is teleported OnTargetObjectWarped happens, and the rig just looks at where it was and where the target is, and moves the brain according to its last known relative position and orientation. However for this use case it should have also evaluated that the Brain has also been warped and indeed transformed.

    If that is a weird edge case behaviour you don't want to evaluate when an object is warped that's fine, but then setting the last frame invalid should also make sure the camera checks if it is in a valid relative position, and not try to snap as if only the target warped, or there needs to be a seperate call to tell the camera that it was also moved.
     
  32. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    You must distinguish between axis input and axis value. The axis keeps a value, which defines the FreeLook's relationship to the target. Mouse input will change that value while there is input, but when the input stops, the value remains fixed. That's why the FreeLook's relationship to the target remains unchanged after the warp. It is correct behaviour, because the FreeLook's job is to position and rotate the camera as a function of the target's location and the axis values, and the axis values are controlled by the user, not by the FreeLook.

    If you want to reset the axis values when teleporting then you must do so manually, as I suggested in my previous post. Setting the position and rotation directly will not be effective, as the FreeLook will overwrite them in response to axis values and target position.

    upload_2020-1-10_8-32-29.png

    You might then ask the question: what are the correct axis values to set? The answer to that depends on your FreeLook settings. If you would show me the inspector and describe to me the desired FreeLook-to-target relationship after the teleport, I might be able to help you with that.
     
  33. awiebe

    awiebe

    Joined:
    Oct 16, 2018
    Posts:
    14
    Hi Gregoryl, I've taken the time to look a little more into the cinemachine, and from what I understand the input values define a rotational offset relative to whatever is defined as the heading. I figured there might just be an event for telling Cinemachine that my heading has changed OnTargetObjectWarped() can tell it my position has changed, but that doesn't seem to be the case.

    I tried just setting the values of m_AxisX.value, but that was a really bad idea because it confused Cinemachine about the constraints and also didn't properly reorient the camera on the way out of the portal.

    Long story short I'm tired of guessing how cinemachine works, and I'd like to take you up on your offer of helping me set the values.

    I have attached my inspectors as requested all 3 rigs are just using an orbital transposer and a composer so I just posted the top rig.

     
  34. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    You have omitted the Binding Mode from the FreeLook inspector. That's an important piece of info and makes a big difference.

    Also you seem to be using an outdated version of Cinemachine. Which one?

    And finally, you need to describe to me the desired camera-target relationship after the warp.

    And even more finally, if you could send me a baby test project having just a target and a FreeLook, with your camera controller code, and that implements a warp, it would make this whole process much more efficient.
     
  35. awiebe

    awiebe

    Joined:
    Oct 16, 2018
    Posts:
    14
    1)Bind mode is World
    2)it was 1.3.3, but I just updated it to the latest 1.6.x and problem persists.
    3)Here is the basic principle of doing a portal

    -We have a second camera that renders an area where we want to warp the player.
    -This camera renders into a render texture at the resolution of the screen or higher.
    -We have a portal plane with a shader that samples this texture using the screen space coordinates, the result of which is that the plane geometry basically acts as a mask for the rendertexture, which shows the world exactly as we want it when the player is teleported.

    In order to teleport the player seamlessly
    1)The main camera and portal destination camera must have matching field of view and possibly other aspects.
    2)When we warp the player, the Camera and player must have the same relative position to each other but the system must be reoriented so that the actual camera matches the position and orientation of the portal camera.

    NB That's not quite right you have to compensate for weird orientation of the player and camera because you'll be spat out at a strange orientation not aligned with the floor if you do that. But I couldn't even get to the step where my camera is in a reasonable starting point so I haven't investigated that yet.

    Getting the position right is not so difficult, but we can't just manually reposition the free cam because it snaps right back into place.

    Things I've tried

    Solution: Have a fixed Virtual Camera and at the destination, and hope the interpolation just works.
    Problem: The camera tries to snap into a weird relative position as soon as I go from fixed back to freelook

    Solution: Parent the player in the camera brain, move and orient the camera brain to match the portal camera, and then unparent the player
    Problem:The camera assumes the same relative position to the player as soon as the frame ends, even though the player is facing a different way, so you would think that the target heading would be updated, and the axis values would move to compensate, but that doesn't seem to be the case.

    If this has something to do with the coordinate system binding, because I'm using world coordinates and not fixing to the target I can see why maybe it behaves that way.

    Solution:Try playing with different coordinate bindings
    Problem:TThis might be the right thing to do, but if I use this the camera relative control in the example project (3D platformer lite) break.

    4)Example project
    https://github.com/awiebe/PortalCinemachine

    Pertinent scripts are PortalTrigger.cs
    Open the Portal "Demo Scene", play and walk towards the plane which is projecting an image
    (try not to do this too quickly I haven't worked out the kinks of zeroing the player's velocity on teleport)
    When you contact the plane the player will be warped to the location of the camera which was producing the image for the portal, t with an identical offset to the destination camera as their local offset from the main camera on entering the portal.

    The player will also have been rotated so that they are facing as if they had just exited the other side of the portal, that is facing the same direction as the camera that produced the portal image. The editor will then Debug.Break()

    The trouble is as shown that the player has moved, and the camera has moved but my attempts to get the cinemachine camera to match the portal's camera, so the match cut is seamless have failed.
     
    Last edited: Jun 30, 2020
  36. awiebe

    awiebe

    Joined:
    Oct 16, 2018
    Posts:
    14
    I gave some thought to the orientation problem and the most logical thing to do is to have a second identical freelook rig orbiting a standin for where I want the player to arrive, but it needs to somehow be also rotated by an arbitrary vector.

    If we consider the simple x-z plane case.
    We can have one portal facing (0,0,1) and one portal facing (-1,0,0)

    The orbit and aim of both relative to the follow target of are identical, but the destination is rotated 90°, I am testing if it will just work if I drop an identical camera rig into a transform rotated 90° or whether it still tries to orient to the world instead of the target heading.


    since delayed recentering is an option I assume this means that the camera's freelook orientation is set arbitrarily, and is not relative th=oe the racked object's facing direction when I have the binding set to world mode, and I have to very specifically twiddle the coordinate system biding to get the behaviour I want.
     
    Last edited: Jun 30, 2020
  37. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Thanks for posting the project. I will have a look at it.
     
  38. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    @awiebe I'm a little puzzled by your approach - it seems to me that it will be very difficult to make the transition seamless unless you set things up differently. I don't get where the camera is supposed to be if you approach the static image from an oblique angle. Or I may be misunderstanding what you're trying to do.

    I found something that might be of interest. Sorry the video isn't in English, but he gets a very nice portal using Cinemachine. I think the technique can be adapted for a 3rd-person camera.



    Is that the effect you want to achieve?
     
    gaborkb likes this.
  39. felix_of_mars

    felix_of_mars

    Joined:
    Jul 25, 2013
    Posts:
    21
    Did anyone get this to work successfully, I have tried the most applicable suggestions and it's clear that there is some chase "velocity" on the camera when it's teleported that is causing it to look like it's popping. I am guessing this must be "by design" as you get the same effect when you initially press play e.g. the camera will attempt to "rubber band" to match the speed of the character (in my case an aircraft.) I might just go back to writing my own camera script as it offers better control.
     
  40. felix_of_mars

    felix_of_mars

    Joined:
    Jul 25, 2013
    Posts:
    21
    Okay, so the issue is with the dampening, if I set x, y, z and yaw to zero it seems to work as expected. Is there a way of dealing with this?
     
    DungDajHjep likes this.
  41. pencilking2002

    pencilking2002

    Joined:
    Sep 30, 2013
    Posts:
    23
    imknown123 likes this.
  42. TomGoethals

    TomGoethals

    Joined:
    Jan 29, 2022
    Posts:
    46
    Hi I'm trying to do exactly this and face the same issue as Felix is facing.

    I'm using a VCam with 3thPersonFollow and Aim Composer.
    It's following a character that gets teleported (using portals, position and rotation is changed) around the map.

    Setting PreviousStateIsValid does the trick but cancels all "velocity" and causes the pop as soon as the camera is teleported and tries to catch up again according to the dampening settings.

    Is there a way to record the local "velocity" or "easing" and setting it again after teleporting?

    A helper method that makes this easier would be much appreciated.
     
  43. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Yes, you can call vcam.OnTargetObjectWarped(target, targetPositionDelta).

    3rdPersonFollow + Composer? That sounds wrong. What kind of camera behaviour are you looking for?
     
  44. TomGoethals

    TomGoethals

    Joined:
    Jan 29, 2022
    Posts:
    46
    Hi Gregoryl,

    Thanks for the support!
    OnTargetObjectWarped does do the trick but it does not account for the instant rotation of the target object.

    I'm looking for a smooth follow behind the character.
    Any rotation with a damping will currently mess up the transporting.
    Only "Hard look at" or "Same as Follow Target" with a damping of 0 will currently make it look good when teleporting.

    I've recorded a video showcasing the issue. (issue shown at 5m07s)


    Any help or hint on how to fix a damped rotation would be very much appreciated!

    Best regards,
    Tom
     
  45. doreenholley

    doreenholley

    Joined:
    Aug 29, 2019
    Posts:
    10
     
  46. doreenholley

    doreenholley

    Joined:
    Aug 29, 2019
    Posts:
    10
    How do I get Cinemachine to appear in the menu bar? Attached screenshot. I want to create a virtual camera.
    I stumbled upon Cinemachine when I downloaded Playground - FP Core.
     

    Attached Files:

  47. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    That's a screenshot from an older version of Cinemachine. It no longer appears in the top-level menu. Instead, you can find it in the GameObject menu (or just right-click in the hierarchy).

    upload_2022-11-10_9-5-17.png
     
  48. Niter88

    Niter88

    Joined:
    Jul 24, 2019
    Posts:
    112
    Strange that no one made a solution to that yet.
    Solved it using the PreviousStateIsValid bool.

    It zeroes the lerp to position and aim, so if it happens while the player is moving they'll notice it.
    Since I'm just using it for floating point fix on an app I think I'll keep that blimp for now.
    If it was an action game with a teleport skill I would be crying right now. Really wanted Unity to give us a tool to solve that on a more elegant way.

    I've made a component, you can use it.
    Just make a script like this and add it to the virtual cameras you'll want to reset.
    Code (CSharp):
    1. using UnityEngine;
    2. using Cinemachine;
    3. using System;
    4.  
    5. public class VrCamForceUpdate : MonoBehaviour
    6. {
    7.     public static Action VrCamForceResetAction;
    8.     CinemachineVirtualCamera cam;
    9.  
    10.     void Start()
    11.     {
    12.         cam = GetComponent<CinemachineVirtualCamera>();
    13.     }
    14.     private void OnEnable()
    15.     {
    16.         VrCamForceResetAction += ForceResetCam;
    17.     }
    18.     private void OnDisable()
    19.     {
    20.         VrCamForceResetAction -= ForceResetCam;
    21.     }
    22.     public void ForceResetCam()
    23.     {
    24.         cam.PreviousStateIsValid = false;
    25.     }
    26. }
    27.  
    Then after you teleport the player you'll do
    Code (CSharp):
    1. VrCamForceUpdate.VrCamForceResetAction?.Invoke();
    EDIT: If you have a DeadZone on your aim, setting it to zero will help a lot on the visuals.
     
    leohilbert and Valerion like this.
  49. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,363
    And it's 2024 and there's still no "make the FreeLook warp to follow a warped target with position AND rotation."

    Also, trying to spawn the character with an exact FreeLook angle behind the player regardless of where Camera.main was in the Editor still has janky coroutine workarounds and is flaky if there are any other lower-priority VCams that just happen to steal the brain's attention while you're trying to manipulate the FreeLook.
     
  50. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Have you tried freeLook.ForceCameraPosition()?