playMaker

Author Topic: How to send 3D gameobject to 2D UI location on screen??  (Read 383 times)

Neikke

  • Full Member
  • ***
  • Posts: 134
    • View Profile
How to send 3D gameobject to 2D UI location on screen??
« on: October 10, 2019, 11:05:53 AM »
Hi,

I need to send coins which my player is collecting to a specific UI location where my Coin Meter is. Currently I kind of made a workaround - I'm sending coins to the hidden gameobject which is roughly aligned to a position of UI Coin meter element. But it's wrong of course - the minute I have different resolution or different aspect ratio those positions get screwed..

Which actions you would recommend for converting worldspace coords to screenspace, and how would you recommend to do that? Thanks a lot in advance!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15467
  • Official Playmaker Support
    • View Profile
Re: How to send 3D gameobject to 2D UI location on screen??
« Reply #1 on: October 11, 2019, 02:17:22 AM »
Hi,

 for this you should use a virtual plane in front of the camera and use the action "ScreenTo3dPlanePoint" on the ecosystem,

get your screen point, and define the plane in the 3d space ( along the z axis of the camera at x distance) where you want the corresponding 3d position.

use that to control a dummy object, and have your coin moving towards that dummy, and once locked, make it a child of it. you will have a problem of scaling, so I would suggest that your dummy is visible at least during editing and scale it up so that it fits your UI, then adjust the scale of the coin as you move towards to end up fitting in that dummy object ( use a sphere collider to witness the size of it without showing it in the game view)


Bye,

 Jean