Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add look-ahead properties #160

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add look-ahead properties #160

wants to merge 1 commit into from

Conversation

BenjaTK
Copy link

@BenjaTK BenjaTK commented Dec 29, 2023

It only works in 2D and in simple mode because I don't think it could be useful for 3D or the other modes but I can try adding them there too. Also I think the damping when it stops is being a bit weird but I saw in the roadmap that was being fixed.

Tgeq3QhUDG.mp4

Let me know if everything's okay! Not too used to how the structure of PhantomCamera works but I did my best.

@ramokz
Copy link
Owner

ramokz commented Dec 30, 2023

This is great! Thank you for putting this together. Re: code structure, it looks well integrated, so no particular comments!

Do believe that the feature can be very useful for 3D, thinking of top down or side-scrolling projects in 3D environments, and some of the other Follow Modes, like Framed Follow. So don't think it needs to be restricted to just 2D and Simple Follow, however, not super critical to sort out at this point.

Been digging into this feature and general concept a bit further, and I am wondering if there is a need for some additional properties. Mainly thinking of interpolating the Look Ahead offset changes, so it doesn't snap in a particular direction when you move, but rather gradually eases towards it.

Cinemachine uses something called Look Ahead Time (float), which, from my understanding, effectively dictates where the target will be X seconds in the future based on that property's value + the target's velocity ((global_position - prevGloPos) / delta - I think). Effectively, determining the distance of the camera as you move in a given direction, which looks similar to the properties you've added here. In addition to that, they're also using a Look Ahead Smoothing (float) property, which dictates how gradual the Look Ahead pushes the camera towards that final distance. My guess is that they're using that value to interpolate to the final Look Ahead distance.
Don't necessarily know if their way is an optimal way of doing it, but what I like about it is that the Look Ahead distance is determined by how fast the target moves rather than a specified value. E.g. if a follow target's movement has some degree of acceleration, it will gradually move the camera as the target's velocity increases. I do also like that it won't be affected, at least not directly, by the Follow Damping. Since it allows someone to have different levels of camera smoothness for Follow and Look Ahead, rather than tying the two together.

Think where your existing properties could come in handy, which I don't believe I've seen applied before but could imagine being useful, is to act as multipliers. Given the idea of Look Ahead Time is based on time + velocity, it means that you would be bound by the properties to affect both axis equally - assuming the velocity between the x/y axes are identical. Whereas a horizontal and vertical parameter could be a potential way to support some additional fine-tuning. Granted, I don't know if it would be an overly desired feature, it at least provides the user some additional control.

@BenjaTK
Copy link
Author

BenjaTK commented Jan 2, 2024

Hey! Sorry for being so late, but I don't think I'll be able to work on this for a long bit. If anyone wants to supersede this, go ahead. My coding skills have a limit anyways lol.

@ramokz
Copy link
Owner

ramokz commented Jan 2, 2024

No problem at all! Happy to take a stab at it at some point.

Thanks again for starting the feature implementation 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants