You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a margin setting (at least for one "primary" element) for nodes in the follow_targets group when using the group follow mode.
The margin would ensure that the area described by the margins would always be inside the viewport.
Use Cases
I am currently working on a top-down shooter style game. I have set up a camera to follow the player, while dynamically being offset to follow the mouse cursor. This is because you want to be able to see further in the direction that you are aiming, rather than having the camera centered on the player. The way I am achieving this is by having an invisible Node2D that follows the mouse cursor and adding it to a follow group with the player. I want the camera to stay at a fixed zoom, and keep both nodes in the frame simply by moving. This should work fine because the cursor is locked to the window so it doesn't have any way to go too far from the player.
I also want some minimum distance between the player and the edge viewport. Because the group follow mode calculates its target based on the global position of the target nodes, it will only ensure that the center of the nodes are in the frame. eg
Currently I am able to get around this by adding four Node2D objects as children of the player at relative positions of (-40,0), (40,0), (0, 40), (0, -40) and adding them to the target group. Result here:
This is pretty clunky to set up though and tweaking the margins is tedious as I need to individually go into all 4 nodes. It would be nice if there was a margin parameter that could create and add these nodes to the group automatically.
(Optional) Proposed Solution
The solution for my use-case is pretty straightforward and I would be happy to implement it but I am not sure how to expose the values in a way that feels clean. While writing this up I realised that it might actually make the most sense for this to be a completely separate follow type. The reason this works in my specific use case is because the cursor is indirectly tied to the main target of the camera. If a second target was added that was completely independent then there is no way to capture both targets without changing the zoom level. Having said that, this setup feels generic enough that there is probably value in adding it as a new type.
The text was updated successfully, but these errors were encountered:
If I understand it correctly, and to summarize, you're looking for a way to apply a margin to individual targets within a follow group? Kinda like if you could apply a Vector4 margin to each Node2D array target?
Essentially what I am going for is the inverse of the "Framed" follow mode. Instead of a deadzone that moves the camera when the node hits the boundary, you offset the camera and it can't move past the boundary around the followed node.
When I was thinking about generalizing this I realized that generalizing it to apply to multiple nodes in the array doesn't really work (since I am using a fixed zoom) so while I was able to create the effect using follow groups it might make more sense to support it as a different mode if creating a simpler interface for this style of camera.
Project Type
2D
Feature Description
Add a margin setting (at least for one "primary" element) for nodes in the follow_targets group when using the group follow mode.
The margin would ensure that the area described by the margins would always be inside the viewport.
Use Cases
I am currently working on a top-down shooter style game. I have set up a camera to follow the player, while dynamically being offset to follow the mouse cursor. This is because you want to be able to see further in the direction that you are aiming, rather than having the camera centered on the player. The way I am achieving this is by having an invisible Node2D that follows the mouse cursor and adding it to a follow group with the player. I want the camera to stay at a fixed zoom, and keep both nodes in the frame simply by moving. This should work fine because the cursor is locked to the window so it doesn't have any way to go too far from the player.
I also want some minimum distance between the player and the edge viewport. Because the group follow mode calculates its target based on the global position of the target nodes, it will only ensure that the center of the nodes are in the frame. eg
Currently I am able to get around this by adding four Node2D objects as children of the player at relative positions of (-40,0), (40,0), (0, 40), (0, -40) and adding them to the target group. Result here:
This is pretty clunky to set up though and tweaking the margins is tedious as I need to individually go into all 4 nodes. It would be nice if there was a margin parameter that could create and add these nodes to the group automatically.
(Optional) Proposed Solution
The solution for my use-case is pretty straightforward and I would be happy to implement it but I am not sure how to expose the values in a way that feels clean. While writing this up I realised that it might actually make the most sense for this to be a completely separate follow type. The reason this works in my specific use case is because the cursor is indirectly tied to the main target of the camera. If a second target was added that was completely independent then there is no way to capture both targets without changing the zoom level. Having said that, this setup feels generic enough that there is probably value in adding it as a new type.
The text was updated successfully, but these errors were encountered: