Hello Guest

Author Topic: Please, help me to position 2D Ortho Sprites relative to a 3D camera view...  (Read 3663 times)

wakestudios

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Wake DevBlog
I'm working on a dungeon-exploring 3D game using Tk2D for GUI and HUD elements in the screen I want to achieve this result:


But as I don't know what I need to do, this is what I get:


Is there a viewport matrix operation involved? Or ScreenToWorldPos-like command?
It looks like a similar approach to get a Minimap in a game, isn't it?
I can't figure which method is more correct. Should I detach HUDs from the TK2DCamera_GUI and place them inside every 3D Character instead?


What would you guys do?


Thanks a lot, of course...


If you cannot see the images, please go to the next urls:
ref-img1: http://imgur.com/T4kL6Ai
ref-img2: http://imgur.com/XXgtyfa

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Get the position from the character -
Vector3 screenPoint = camera3d.WorldToScreenPoint(charHeadPosition);
Get a world position in the gui camera
Vector3 worldPos = cameraGUi.ScreenToWorldPoint(screen point);

Position your gui hud element to this worldPos (maybe messing with the z a little bit) and it should appear where it should.

wakestudios

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Wake DevBlog
Seems to be scaling a little when your character get close to the Camera.   Other than that, works perfect!


Thx a lot. You saved my life :)