Forum rules - please read before posting.

Pan Camera Based on Hover Direction

edited January 3 in Technical Q&A

Hi all!

Hope you are doing well --

I was wondering if it is possible to create a camera that scrolls in the direction of the cursor when you reach the edges of the camera view port and is limited by a sprite background.

With an example with the terms I used above --

So it's similar to the navigation in this map (sprite background) right here (roughly timestamp 1:23 - 1:30) -- where the user is hovering at the right edge of the map and the "plane" (cursor) is moving in that direction (right) until they reach the right edge of the map, which is when the camera stops moving further to the right.

Video:

Would this require a modification of GameCamera2DDrag? If so, how?

Any help is appreciated, thank you!

Comments

  • The Drag camera relies on the change in cursor position, rather than the position itself.

    You could try checking Follow cursor? in a regular GameCamera2D, but it may not give the exact behaviour you're looking for.

    If you wanted to go the custom route, you can create custom Camera behaviour by attaching a Basic Camera component to a regular Unity camera (which allows it to be available in AC Camera Actions/fields), and then also attaching your own custom script that derives from MonoBehaviour.

    Though, a slightly cheaty/hacky way to do this might be to just have a regular 2D camera follow an invisible target, and then move the target instead. This could even be your Player character, if it was for a separate map screen.

  • Ah the Follow Cursor? With the GameCamera2D was the exact behavior I was looking for -- thank you so much!! :)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.