Splitscreen ui problem

Hey,
I hope someone is able to help me as I am in a bit of a bind :slight_smile:
I have a splitscreen game setup(several cam’s with different viewport rects), and i am trying to have arrows(for each camera point at the other players(when they are not in view).

What i have so far works technically, but all the arrows are moving in the middle of the screen, as if it is just one camera. however, when there are 3 cameras and one of the cams is larger, the arrows also follow that size.

This is my current code :

  • foreach(Transform plyr in players)
  • {
  • if(!plyr.GetComponent().IsVisibleFrom(cameraT))//custom function that checks if the player can be seen by cameraT(which is the individual camera
  • {
  • foreach(Image arrw in arrows)
  • {
  • if(arrw.GetComponent().followId == plyr.GetComponent().playerId)
  • {
  • Vector3 screenPosViewport = cameraT.WorldToViewportPoint(plyr.transform.position);
  • Vector3 screenPosViewportClamped =newVector3(Mathf.Clamp(screenPosViewport.x,0.04f,0.96f),Mathf.Clamp(screenPosViewport.y,0.04f,0.96f),0);
  • Vector3 v3 =newVector3(screenPosViewportClamped.x * cameraT.pixelWidth -(cameraT.pixelWidth/2), screenPosViewportClamped.y * cameraT.pixelHeight-(cameraT.pixelHeight/2),0);
  • arrw.transform.localPosition = v3;
  • }
  • }
  • }

I have also attatched an image, trying to illustrate what is wrong(arrows point to where the arrows “should” be.

Also, I am aware of using canvas world space, but I would rather not instantiate 6+ canvases, instead of just making this work :slight_smile:

Hope someone can help, thanks.

I’ll be honest and say you probably shouldn’t use UI for this scenario. Main reason being you are going to have to tackle the whole screenspace to worldspace conversion for figuring out which direction to point on each camera.

Might be better to treat it like any other GO, either using a 3D arrow with it’s forward matrix just pointing at the other character, or a 2D sprite doing the same on screen.

My 5 pence worth.