#Corner

1 messages · Page 1 of 1 (latest)

old echo
#

Current code to position the text at the corner (not based off camera)

private void Logic(Transform Object) {
        if (LastHovered == null) 
            return;

        Text.gameObject.SetActive(true);

        Camera Cam = Player.Character.Cam;
        Collider Col = LastHovered.GetComponent<Collider>();

        Vector3 WorldMax = Col.bounds.max;
        Vector3 LocalMax = LastHovered.InverseTransformPoint(WorldMax);

        Vector3 Offset = new Vector3(
            LocalMax.x / 2, LocalMax.y / 2, 0f
        );

        Vector3 ScreenPosition = Cam.WorldToScreenPoint(WorldMax + Offset);
        Text.transform.position = ScreenPosition;
    }