playMaker

Author Topic: How to move one GUI element to another GUI element over time  (Read 2304 times)

Zswag

  • Playmaker Newbie
  • *
  • Posts: 9
How to move one GUI element to another GUI element over time
« on: March 14, 2019, 06:32:19 AM »
I have a gui of a coin, that id like to move towards the stat bar, how can i do that? Ive got the position of the coin already sorted, just need to move it gradually

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
Re: How to move one GUI element to another GUI element over time
« Reply #1 on: March 14, 2019, 07:08:50 PM »
I'm not sure what task do you solve, but it looks like you just need a "slider" element. GameObject->UI->Slider. And assign a coin as handler. This way you can create a stat bar and a coin will show the current value on this start bar.
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

jasperPT

  • Full Member
  • ***
  • Posts: 115
  • I am a VFX Animator teaching myself to make games
Re: How to move one GUI element to another GUI element over time
« Reply #2 on: March 17, 2019, 03:52:26 PM »
You will want to look at a tweeting package most likely.
Personally I use tween machine which can be bought from the asset store, there are playmaker actions for it and it is much more reliable and performant than Itween which comes by default with playmaker. This will allow you to animate all kinds of parameters on objects including their position
You could use the action “lean tween move to” to animate one object to another.

Or if you want to be more complicated you can get the start /end positions, do some calculations of a kid point and use one of the tween along curve actions to make the coon move in an arc to its destination.

Hope that helps.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to move one GUI element to another GUI element over time
« Reply #3 on: March 17, 2019, 08:37:13 PM »
Hi.
To move in side the Ui, you can use "Rect Transform Set Local Position"

first you need to have the starting point of the coin and the end point.

Then use for example a "Vector3 Interpolate" or some vector 3 tweening.
and with the result you can move the coin with the "Rect Transform Set Local Position" (set to Every Frame)

To get the starting point from a world object, i believe you can use "Rect Transform World To Screen Point"

To get the end point you can set an empty object to the position you wish the coin has to go.

Then use "Rect Transform Get Local Position" to get the position