playMaker

Author Topic: Move Towards Problems  (Read 4630 times)

Mayhem

  • Full Member
  • ***
  • Posts: 171
Move Towards Problems
« on: March 04, 2013, 12:48:05 PM »
Hey there,

so i'm working on my UI with nGUI (for an iOS Game). For now, there are just some Buttons which can be tapped. I made my UI with the nGUI-Plugin, made the ImageButtons and attached the UIEventsToPlaymakerFSM Script (which i downloaded here in the forum, thanks for that :D ) to the Buttons. Works fine!

But, the thing is: I have a "Pause"-Button, when it is clicked, i want that another GameObject come up (this GameObject is another UI-Object, which has three Other Buttons).

My first approach was like this:

- the other Menuobject is deactivated
- when the PauseButton is tapped, it activates the MenuObject
- then i Use "Move Towards" like this:

I used the Move Towards-Action, but i didn't get the results i wanted to.

So, the Strucutre is like this:

The "SystemMenuPanel" is a Panel with a nGUI-Sprite and three Buttons.


This is the "Transform" of the UI


This is the "Transform" of the SystemMenuPanel


These are my MoveTowards-Settings


So as you see, i want the Object just to move 10 Units up. If i do so, the Menu floats to a certain point in the scene, with these coordinates:



And as you might tell, these are not the droid...the coordinates i'm looking for :)

I wanted it to go from Y: -314
 



To Y: -324.

So, what did i do wrong? :)




« Last Edit: March 04, 2013, 12:52:50 PM by Mayhem »

Mayhem

  • Full Member
  • ***
  • Posts: 171
Re: Move Towards Problems
« Reply #1 on: March 05, 2013, 10:55:17 AM »
No ideas, guys?

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Move Towards Problems
« Reply #2 on: March 05, 2013, 01:46:25 PM »
hey,
my first guess in such a scenario would be global space vs self space. Maybe the move towards action works in global space, and instead you want to use local space. To check if this is true, run the game and unparent your menu , then check if the position is 0/10/0 once it's no longer a child of anything. This seems likely since your self space is very "dense", because the scale of your UI is very small ( for example a scale of 0.001 would make the world distance of 1 to a local distance of 1000 in any child gameObject.)
« Last Edit: March 05, 2013, 01:49:21 PM by kiriri »
Best,
Sven

Mayhem

  • Full Member
  • ***
  • Posts: 171
Re: Move Towards Problems
« Reply #3 on: March 05, 2013, 02:59:48 PM »
Yeah, that was it. It works global. Thanks for that hint :)

So, is there any way to use it "self" and not "global"?

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Move Towards Problems
« Reply #4 on: March 05, 2013, 03:21:55 PM »
Good, that makes it rather simple :) The action "transform point" will take your vector3 and then convert it from a local space of a gameObject to global space.  That way you can turn your 0/10/0 into a global space point and then use that in your move towards action.
Best,
Sven

Mayhem

  • Full Member
  • ***
  • Posts: 171
Re: Move Towards Problems
« Reply #5 on: March 05, 2013, 04:35:46 PM »
Which Vector3 do you mean exactly and how can i convert it via PlayMaker?

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Move Towards Problems
« Reply #6 on: March 05, 2013, 04:45:13 PM »
if you use the action "Transform Point" and put in 0/10/0 (or wherever you want to move your menu), then it will convert this vector3 position from local space into world space. Save the result as a vector3 variable and use that vector3 variable in the Move Towards action (where you put 0/10/0 before).

Does that make more sense?
Best,
Sven

Mayhem

  • Full Member
  • ***
  • Posts: 171
Re: Move Towards Problems
« Reply #7 on: March 05, 2013, 05:14:27 PM »
Ah, yes, now i get it! :)

It worked, but my Vector3 Variable which i created and stored the LocalPosition gets "strange" values, after using MoveTowards:

Transform Point Action:

Local Position: 0/300/0
Store: MoveMenu_V3 (made a blank V3 wit 0/0/0 )

Move Towards Action:
Target Position: MoveMenu_V3
Finish Distance: 0

Looking at the MoveMenu_V3-Vektor in the Inspector, it tells me its values are:
0/-0.1291576/0.0055555556

But it looks right... :D