Hud and Scene coordinates - Can they talk?

HappyKat78HappyKat78 Member, BASIC Posts: 173

Hi All,

I'm trying to get an icon in the hud point to an object on the scene, but it looks like the coordinates of the hud (defined as a non-scrollable layer) refer to the screen size not the scene size. To give an example of what I'm trying to do - let's say you have a spaceship flying around a scrollable scene and you're looking for an object. I want an icon (little arrow or something) that indicates which direction the object is in relation to the spaceship when the object is not on the screen. Has anyone done anything like this?

Any help very much appreciated!

Cheers,

HK

Comments

  • SocksSocks London, UK.Member Posts: 12,822

    @HappyKat78 said:
    Hi All,

    I'm trying to get an icon in the hud point to an object on the scene, but it looks like the coordinates of the hud (defined as a non-scrollable layer) refer to the screen size not the scene size.

    Coordinates relate to position rather than to size.

    @HappyKat78 said:
    To give an example of what I'm trying to do - let's say you have a spaceship flying around a scrollable scene and you're looking for an object. I want an icon (little arrow or something) that indicates which direction the object is in relation to the spaceship when the object is not on the screen.

    Point the arrow at:

    Object X - scene.camera origin X
    Object Y - scene.camera origin Y

  • SocksSocks London, UK.Member Posts: 12,822
    edited October 2015

    The above will get the arrow on your non-scrollable HUD to point to the object on the scrollable layer.

    Where constraining the arrow rotation to . . .

    vectorToAngle (object X - spaceship X , object Y - spaceship Y)

    . . . will have the arrow display the direction from the spaceship to the object.

  • HappyKat78HappyKat78 Member, BASIC Posts: 173

    Thanks Socks. The trouble I've had though is that the coordinates in the HUD layer are not related to the scene, but rather the position within the screen size / camera. For example, let's say my screen size is 480x320, but my scene is 960x960. If my camera's x position is scrolled to the far right of the scene so covering the scene x coordinates of 480 to 960, and I have an icon in my HUD layer in the middle of the screen, it's x position shows as 240 (half the width of the screen), not as 720 (which would be it's actual position on the scene). Sorry if I'm not being clear. Does that make sense? Something I'm doing wrong?

  • SocksSocks London, UK.Member Posts: 12,822
    edited October 2015

    @HappyKat78 said:
    Thanks Socks. The trouble I've had though is . . . .

    Did you try either of the suggestions ?

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @Socks said:
    Did you try either of the suggestions ?

    ...

  • HappyKat78HappyKat78 Member, BASIC Posts: 173

    I did. The first one didn't seem to point to the actual target but did rotate. The second didn't rotate at all. There's a good possibility I'm not following the instructions right. But as the arrow in the hud layer sees itself on different coordinates as the object in the scene I thought that might be why it's not working?

  • SocksSocks London, UK.Member Posts: 12,822

    @HappyKat78 said:
    I did. The first one didn't seem to point to the actual target but did rotate. The second didn't rotate at all.

    Strange ? Could you post a quick screen grab of your rules ?

    @HappyKat78 said:
    But as the arrow in the hud layer sees itself on different coordinates as the object in the scene I thought that might be why it's not working?

    They are both using the same coordinate system, moving the camera may offset its origin, but all actors are still in the same scene, so their positions are related.

  • HappyKat78HappyKat78 Member, BASIC Posts: 173

    Ok, I'm not sure how to post pics on here, but I'll see if I can provide more information on what's actually happening when I try these suggestions. I'm at work today (yeah, have a "real" job) so will try and post something later. Thank you very much for your help! It's really appreciated!

  • HappyKat78HappyKat78 Member, BASIC Posts: 173

    Hi, I got this working, so wanted to say thanks! I simplified it and just had the arrow point to the object and not try and move to a particular point on the screen.

    Again, thanks very much for the help!

    HK

Sign In or Register to comment.