Here’s a snip of the code to keep the camera centred between 2 objects, Object1 & Object2. It also zooms in or out so that the two objects are always both on screen.
It will zoom in no closer than the original scene window size (the first part of _zoom = (min(1, ....), but will zoom out indefinitely.
This is great! I have added this idea to the list of Extension ideas.
Do you think it could be modified to work for all instances of objects? Meaning, keep all instances of an object on the screen? (this should work with object groups as well)
Can you use LERP on the camera changes in case the objects move quickly to prevent jarring movement?
I’ll try it out, thanks
Edit: So at first I tried changing the actual variable but then I realized that was not gonna work since at the beginning of the scene the value is changed to something else. Then this worked just perfectly : ) Thanks to both you for helping out.
If you create an extension for this please consider the following requirement: There should be a MaximumZoom that is configurable, and when set prevents the tracked objects from moving in a direction that would cause the MaximumZoom to be exceeded.
This is a very common consideration for games that use this type of zooming.
Uh I just realized you opened a trello… I’ll post this there
How does your code work when there are multiple instances of an object? I expect it will set the variables based on the last instance created.
l was thinking about changing this to use a single object parameter (which can also be an object group) and do a ForEach() to find the min/max X/Y for all instances. Do you think that is a good design?
It’s still not perfect, because in the loop it should ideally take into account the object’s size and position when calculating the extremes. But this’ll have to do for now.
@tristanrhodes, I need to admit I’ve never made an extension, so go ahead and make an it if you like.
I’ve had a think about the improvement I mentioned in my last post, and think I see a simple way to implement it.
Give me a PM about the author field text and any other details you need, and I’ll also see about getting you the code in JSON or some form that you can copy and paste easily.