Hey - I think I need to modify a specific small part of the package but I don’t know how to do it without worrying about not being able to restore it to the original state.
Background to the problem :
I am still making the racing game in which player is automatically propelled forward and can change “the line” left or right to avoid obstacles or gather a coin.
I decided to make a player controller by using a dolly track camera and a dolly cart that go through the middle of the road at some speed. The player is “pushed by camera” along the way forward.
New Chunk spawns when pink trigger activated. Every 3 new chunks the DollyTrack is swapped to the new one (The 3 newly generated tracks)
The problem occurs during the swap - The camera along with the player is always teleported to the end of the new track before being erratically transported to it’s beginning. I thought that it is caused by the parameter of the DollyCart (position - position along the track) or the same parameter of the Cinemachine dolly camera, but resetting it to 0 didn’t change a thing.
Waypoints of Cinemachine dolly camera are stored in an Array. I suspect that by doing this operation :
The waypoints may be copied fom the end to the beggining which makes the player teleport to the end every time. I want to change the whole class to List, so it can append new waypoints from the beginning to the end. I don’t want it to teleport to the end. I just want it to continue on it’s path further along the road. (ad Infinitum)
I made a variation of CinemachineSmoothPath class. I just changed array usage to lists. The editor didn’t complain, but the visuals inside the editor view didn’t work. So I looked into CinemachineSmoothPathEditor and tried to change that one, but for some reason it can’t find “BaseEditor” Template class that needs to be inherited from.
At this point I’m not sure what should I do. Do you think there is a simpler way to solve the player teleport problem ?
Should I just modify the package on the spot and save it as my own package locally ? Can I disable the original cinemachine so I don’t have to change all the class names in that case ?
When I want to teleport an object with “loose” children, I have a system to do it.
On the loose children (such as a vcam), put a Teleportable behavior, which means they should teleport along with the owner.
On the owner (such as player), put a Teleporting behavior, which has a simple list of Teleportables that belong to it.
Teleporting.Teleport() calls OnPreTeleport() for all the known loose parts, where I can parent them or memorize their positions. Then it does the movement appropriately (transform, rigidbody, charactercontroller, whatever). Then it calls OnPostTeleport(), where I can unparent or adjust their new relative positions accordingly.
No modifications to Cinemachine, but it calls on the right CM functions as necessary to blink over without blending.
I think the issue here is assigning a new path position to the camera that keeps the camera in the same world position it had before you changed the path points. There are a couple of potential issues here:
Finding the correct value for PathPosition
Dealing with damping
IMO it’s best to separate these things. First turn off the DollyCamera’s position damping and let’s see if we can deal with the first issue. Have you tried using path.FindClosestPoint() to get the new path position?
To answer your initial question, you can embed Cinemachine into your project by moving it from your project’s package cache (inside Library) to your project’s Packages directory. Then, you can add it to your source control and modify it as you wish. It’s not a great solution because then it becomes difficult to upgrade Cinemachine in the future, so you really only want to do it as a last resort.
Another option is to implement your own path logic (inherit from CinemachinePathBase), but then you need to implement all the inspectors etc.
And finally, your proposed change of Array to List might solve the initial problem, but it will create performance issues when the path gets long and you don’t trim off the old points - but doing that will re-introduce this issue, so you’re better off figuring out how to fully replace the path.
Ok - you were absolutely right about damping it needs to be 0 when the path-swap occurs.
I circumvented the camera problem by using an invisible cart on the Dolly path that has 3rd person camera attached to it.
Thank you very much ! I’ve been stuck on this problem for a very long time.