Is it possible to show different sprite animations for different camera

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Robotex

I have a split screen RTS game. I play different sprite animations for selected and not selected units. But when I select the unit, I see selected animations for this unit on both screens.
Is it possible to show selected animations only for one camera and not selected for the others?

:bust_in_silhouette: Reply From: Andrea

i’m not sure you can, the sprite is an object of the world, if you have 2 cameras looking at the same world, they’ll see the same thing.

In 3D there is a cull mask property for the camera, and every mesh has a layer property: the camera will only render the mesh in the same render layer of its cull layer.
I cant find the same option for the camera 2D, i dont know why (although the project setting menu has both the 2D and 3D render layer name window, so i think somehow is possible to set the cull mask for the 2D camera as well)

if you can manage to find it, you simply need to place 2 sprites on 2 different render layer, and assign each camera to each layer. You can now control them separately


EDIT: i checked and confirm that cull mask is not present in 2D. I thought it was possible to emulate the effect with light mask, but the same issue is present, camera2D has no way to render light layers selectively

Is it possible to do by the shader material?

Robotex | 2021-03-21 15:32

i wouldnt know how, the problem is not the material/sprite itself, but the camera, since i dont know a way to tell a specific camera what to see and what to exclude.
said so, it seems strange this feature is present on 3D but not 2D, i would maybe post a question on the github (if nobody else answer here)

here a similar post that was easier to solve (cause the camera was 3D)

Multiple viewports: only render some objects in some viewports · Issue #2179 · godotengine/godot-docs · GitHub

Andrea | 2021-03-21 18:26