I am using dots physics so the collider extension doesn’t do anything? Work around? Thanks
For now, you’ll have to make your own collider extension that queries Unity.Physics.
FYI we are working on a 100% DOTS version of Cinemachine. It’s still in early stages, as the DOTS API is evolving, but it’s looking very good.
@Gregoryl Any updates on the Dots version Cinemachine ??
None that I can share at this time. It’s still a thing.
Hi @Gregoryl ! Are there any guides/suggestions to making Cinemachine work with Unity.Physics without stuttering? My process connecting Cinemachine with DOTS is simple: create hybrid object as child of PhysicsBody. CompanionLink’ed GameObject transform updated via CopyTransformToGameObjectSystem. And I make this gameobject as Follow and LookAt targets for CinemachineVirtualCamera. No matter what I change (CinemachineBrain update method, Aim/Body types) camera not moving smooth along with body. Maybe there are some “official” methods for glueing Cinemachine and DOTS for current state of DOTS packages? Thanks in advance!
@ToniSnyder If the transforms get updated before LateUpdate then CM will see them if the Brain is set to LateUpdate. In that case, you’ll have to do some kind of interpolation to adjust for the clock difference between render deltaTime and the physics fixed time step.
If you’re updating UnityPhysics on the FixedUpdate clock with the brain set to FixedUpdate, then you’ll need to synch the the transforms (without interpolation) after doing the physics update and before CMBrain does its FixedUpdate.
Alternatively, you can put the Brain in ManualUpdate mode and call brain.ManualUpdate after the physics has updated and the transforms have been synched.
Without more info about your game loop I can’t really say why you’re getting stuttering.
Hi there any solution on this problem?
I have almost the same setup as @ToniSnyder . Physics runs within DOTS and I use the CopyTransformToGameObjectSystem to sync the gameobject with the DOTS world.
The Camera follows a Virtual Camera with default settings on it (damp xyz =1)
But doesn’t matter what I setup. The camera is stuttering.
I’ve also written a custom sync system to synchronize Gameobjects as well as update the brain.
I tried to run this in normal update, fixed update,… no matte what I do it stutters.
Any help on this?
[UpdateInGroup(typeof(FixedStepSimulationSystemGroup))]
[UpdateAfter(typeof(EndFramePhysicsSystem))]
[UpdateBefore(typeof(CopyPhysicsVelocityToSmoothing))]
public partial class CinemachineBrainUpdateSystem : SystemBase {
CopyTransformToGameObjectSystem copyTransformToGameObjectSystem;
private EntityQuery m_TransformGroup;
protected override void OnCreate() {
base.OnCreate();
copyTransformToGameObjectSystem = World.GetOrCreateSystem<CopyTransformToGameObjectSystem>();
m_TransformGroup = GetEntityQuery(ComponentType.ReadOnly(typeof(CopyTransformToGameObject)), ComponentType.ReadOnly<LocalToWorld>(), typeof(UnityEngine.Transform));
}
protected override void OnStartRunning() {
base.OnStartRunning();
copyTransformToGameObjectSystem.Enabled = false;
}
protected override void OnUpdate() {
var transforms = m_TransformGroup.GetTransformAccessArray();
var copyTransformsJob = new CopyTransforms {
LocalToWorlds = m_TransformGroup.ToComponentDataArrayAsync<LocalToWorld>(Allocator.TempJob, out var dependency),
};
copyTransformsJob.Schedule(transforms, dependency).Complete();
Entities.WithoutBurst()
.ForEach((CinemachineBrain brain) => {
brain.ManualUpdate();
}).Run();
}
[BurstCompile]
struct CopyTransforms : IJobParallelForTransform {
[DeallocateOnJobCompletion]
[ReadOnly] public NativeArray<LocalToWorld> LocalToWorlds;
public void Execute(int index, TransformAccess transform) {
var value = LocalToWorlds[index];
transform.position = value.Position;
transform.rotation = new quaternion(value.Value);
}
}
}
@Spy-Shifty_1 Stuttering is almost always due to mismatch between the deltaTime used to calculate motion and the deltaTime for the render frame. When a camera is set to track such an object, this stuttering gets magnified - especially if damping is used - because the target will jitter in the frame. If you turn damping to 0, the target will stop jittering in the frame (because the camera will jitter exactly along with it) but you’ll see the background jitter if you look at it. For psychological reasons this is less noticeable, but it’s still happening. The problem is in the target’s motion.
I can’t tell from here where that mismatch is occurring. Possibly it’s aliasing between the physics frame time and the render frame time. Your code is not compensating for this with interpolation.