I just found it impossible to write a FocusFix mod. It has to be done vanillaly.

What feathres do I want:
1. focus on a relative point of an object instead of zero point.
It's useful when focus on a large object. For example, I want to build something on an mountain and want to focus on the mountain top, but the zero point is at the bottom of the mountain.
2. keep camera position when in building mode when the focus target are gone.
When working on a small part of a big machine, usually people focus on a block at that place, and must be careful not to delete the focused block. If you did, you have to refocus which is annoying.

What I have tried to implement this in a mod:
My way is to write my own MyMouseOrbit Component, and replace the vanilla MouseOrbit in Main Camera with MyMouseOrbit. After a long debugging process, I finally made MyMouseOrbit work.

How I failed:
F1 not working, vanilla camera block not working, starting simulation won't focus on the simulation block, stopping simulation makes the focus target lost, and there must be more problems that I haven't notice. Many functions rely on access to MouseOrbit.
I cannot just change every place that rely on MouseOrbit. And some of them are private, or be relied on other components, may be I need to rewrite this game to acheive this mod.
Can you do it vanillaly?


Staff member
Instead of replacing it, try modifying the public values of the already existing one.
If you need to check if the target has changed you can store a reference to the current target and compare it to the one in MouseOrbit in LateUpdate