Playmaker Forum

Playmaker Feedback => Action Requests => Topic started by: krmko on October 01, 2017, 10:29:34 AM

Title: Get global position
Post by: krmko on October 01, 2017, 10:29:34 AM

any chance of someone making this action? I've got a debug script for it, just needs to be put in an action, something i'm not quite confident in yet and i think it will be useful to many :)

Here's the script:

Code: [Select]
using UnityEngine;
 using UnityEditor;
 public static class DebugMenu
     [MenuItem("Debug/Print Global Position")]
     public static void PrintGlobalPosition()
         if (Selection.activeGameObject != null)
             Debug.Log( + " is at " + Selection.activeGameObject.transform.position);

Vector3 pos = Selection.activeGameObject.transform.position;
Debug.Log("pos is now " + pos.ToString("f3"));
Title: Re: Get global position
Post by: djaydino on October 01, 2017, 06:49:27 PM
This is actually a 'Menu item'
so not usable for actions.
i am not sure what you are trying to do, but you could make something like this :

Have an fsm somewhere and in the 1st state have a "on mouse Down" then on the next state have a mouse pick to select the object.
then you can use get position and set space to "world" next you can use debug actions or whatever you need to do (for example 'add to array list')
then after you done what you need to do, use a next frame event and loop back to the 1st state.
Title: Re: Get global position
Post by: krmko on October 09, 2017, 06:58:56 AM
It is a menu item, but the logic is the same. Transform panel in the inspector shows the local position of the object, you have to deparent it to see its global position which is stupid.

Thanks for the tip, but it's too complicated, i'll try making and sharing an action :)
Title: Re: Get global position
Post by: jeanfabre on November 02, 2017, 12:16:09 AM

 can you explain your use case?

 the problem is that you are mixing editor tools with runtime tools, so this action will not work when you pubish it. You may have a good use case though, maybe you want to save data at edit time to use for level edition or something.