playMaker

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - createasaurus

Pages: 1 2 [3] 4 5 ... 10
31
Thank you djaydino.  :D

32
Now that my project is getting bigger, I realize that I have a lot of global variables that I am having trouble keeping organized.

Is putting them in folders or renaming them possible?  Is there some tip or trick you use to keep your globals manageable?

Thank you!!

33
@terri & dudebxl
Ah ha!  Now I understand. This is the first I have heard of ecosystem.  Fantastic!!  Thank you.

34
Quote
There is a Playerprefs Get/Set Bool in the ecosystem that does this
I know this sounds crazy, but I can't find it.

Please see my attached image of what my Playerprefs menu looks like... no Get/Set Bool.  I wonder why I do not have this option?  Please, where do I find or get this?  If I could simply do Get/Set Bool in Playerprefs, it would solve my whole problem.

In the meantime, I'm starting to write a manual workaround using states to change all Bools to Ints, one by one, then Save, then the reverse for Load. (It is cumbersome, and I worry I can introduce error by writing all this out and overlooking something, but I need to do this somehow.)  Furthermore, changing each Int back into a Bool is requiring me to write an Int Switch sending to either a Set to 0 or Set to 1 state... this was the reason for my original post, a request for an Int to Bool action.

Thank you for your thoughts!!

35
I have Ints that are either 0 or 1 that I'd like to convert to Bools.  Is this possible?  Is there a custom action already made for this?

The reason I am doing this is I have Global Bools that I want to save to Player Prefs.  However, there is no Playmaker action to save Bools to Player Prefs that I know of.  So, I'm manually converting all the Bools to Ints then saving to Player Prefs.  Now, for loading, I'm taking these new Player Prefs Ints, and I need to assign them back to Bools.  I guess I could write a long thing out using Int Switch for each one...  I just was wondering if there was a more elegant way.  Thanks!

36
I've been revisiting this problem every few days on my own, but I am still stuck.  I think I may have gotten good advice so far, but I guess it above my skill to implement correctly.

Please if someone would, please look at the script and tell me specifically what to add to be able to access any of the variables such as "set walk speed" in PlayMaker.

With great appreciation.

Code: [Select]
using System;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;

namespace UnityStandardAssets.Characters.FirstPerson
{
    [RequireComponent(typeof (Rigidbody))]
    [RequireComponent(typeof (CapsuleCollider))]
    public class RigidbodyFirstPersonController : MonoBehaviour
    {
        [Serializable]
        public class MovementSettings
        {
            public float ForwardSpeed = 8.0f;   // Speed when walking forward
            public float BackwardSpeed = 4.0f;  // Speed when walking backwards
            public float StrafeSpeed = 4.0f;    // Speed when walking sideways
            public float RunMultiplier = 2.0f;   // Speed when sprinting
        public KeyCode RunKey = KeyCode.LeftShift;
            public float JumpForce = 30f;
            public AnimationCurve SlopeCurveModifier = new AnimationCurve(new Keyframe(-90.0f, 1.0f), new Keyframe(0.0f, 1.0f), new Keyframe(90.0f, 0.0f));
            [HideInInspector] public float CurrentTargetSpeed = 8f;

#if !MOBILE_INPUT
            private bool m_Running;
#endif

            public void UpdateDesiredTargetSpeed(Vector2 input)
            {
            if (input == Vector2.zero) return;
if (input.x > 0 || input.x < 0)
{
//strafe
CurrentTargetSpeed = StrafeSpeed;
}
if (input.y < 0)
{
//backwards
CurrentTargetSpeed = BackwardSpeed;
}
if (input.y > 0)
{
//forwards
//handled last as if strafing and moving forward at the same time forwards speed should take precedence
CurrentTargetSpeed = ForwardSpeed;
}
#if !MOBILE_INPUT
            if (Input.GetKey(RunKey))
            {
            CurrentTargetSpeed *= RunMultiplier;
            m_Running = true;
            }
            else
            {
            m_Running = false;
            }
#endif
            }

#if !MOBILE_INPUT
            public bool Running
            {
                get { return m_Running; }
            }
#endif
        }


        [Serializable]
        public class AdvancedSettings
        {
            public float groundCheckDistance = 0.01f; // distance for checking if the controller is grounded ( 0.01f seems to work best for this )
            public float stickToGroundHelperDistance = 0.5f; // stops the character
            public float slowDownRate = 20f; // rate at which the controller comes to a stop when there is no input
            public bool airControl; // can the user control the direction that is being moved in the air
        }


        public Camera cam;
        public MovementSettings movementSettings = new MovementSettings();
        public MouseLook mouseLook = new MouseLook();
        public AdvancedSettings advancedSettings = new AdvancedSettings();


        private Rigidbody m_RigidBody;
        private CapsuleCollider m_Capsule;
        private float m_YRotation;
        private Vector3 m_GroundContactNormal;
        private bool m_Jump, m_PreviouslyGrounded, m_Jumping, m_IsGrounded;


        public Vector3 Velocity
        {
            get { return m_RigidBody.velocity; }
        }

        public bool Grounded
        {
            get { return m_IsGrounded; }
        }

        public bool Jumping
        {
            get { return m_Jumping; }
        }

        public bool Running
        {
            get
            {
 #if !MOBILE_INPUT
return movementSettings.Running;
#else
            return false;
#endif
            }
        }


        private void Start()
        {
            m_RigidBody = GetComponent<Rigidbody>();
            m_Capsule = GetComponent<CapsuleCollider>();
            mouseLook.Init (transform, cam.transform);
        }


        private void Update()
        {
            RotateView();

            if (CrossPlatformInputManager.GetButtonDown("Jump") && !m_Jump)
            {
                m_Jump = true;
            }
        }


        private void FixedUpdate()
        {
            GroundCheck();
            Vector2 input = GetInput();

            if ((Mathf.Abs(input.x) > float.Epsilon || Mathf.Abs(input.y) > float.Epsilon) && (advancedSettings.airControl || m_IsGrounded))
            {
                // always move along the camera forward as it is the direction that it being aimed at
                Vector3 desiredMove = cam.transform.forward*input.y + cam.transform.right*input.x;
                desiredMove = Vector3.ProjectOnPlane(desiredMove, m_GroundContactNormal).normalized;

                desiredMove.x = desiredMove.x*movementSettings.CurrentTargetSpeed;
                desiredMove.z = desiredMove.z*movementSettings.CurrentTargetSpeed;
                desiredMove.y = desiredMove.y*movementSettings.CurrentTargetSpeed;
                if (m_RigidBody.velocity.sqrMagnitude <
                    (movementSettings.CurrentTargetSpeed*movementSettings.CurrentTargetSpeed))
                {
                    m_RigidBody.AddForce(desiredMove*SlopeMultiplier(), ForceMode.Impulse);
                }
            }

            if (m_IsGrounded)
            {
                m_RigidBody.drag = 5f;

                if (m_Jump)
                {
                    m_RigidBody.drag = 0f;
                    m_RigidBody.velocity = new Vector3(m_RigidBody.velocity.x, 0f, m_RigidBody.velocity.z);
                    m_RigidBody.AddForce(new Vector3(0f, movementSettings.JumpForce, 0f), ForceMode.Impulse);
                    m_Jumping = true;
                }

                if (!m_Jumping && Mathf.Abs(input.x) < float.Epsilon && Mathf.Abs(input.y) < float.Epsilon && m_RigidBody.velocity.magnitude < 1f)
                {
                    m_RigidBody.Sleep();
                }
            }
            else
            {
                m_RigidBody.drag = 0f;
                if (m_PreviouslyGrounded && !m_Jumping)
                {
                    StickToGroundHelper();
                }
            }
            m_Jump = false;
        }


        private float SlopeMultiplier()
        {
            float angle = Vector3.Angle(m_GroundContactNormal, Vector3.up);
            return movementSettings.SlopeCurveModifier.Evaluate(angle);
        }


        private void StickToGroundHelper()
        {
            RaycastHit hitInfo;
            if (Physics.SphereCast(transform.position, m_Capsule.radius, Vector3.down, out hitInfo,
                                   ((m_Capsule.height/2f) - m_Capsule.radius) +
                                   advancedSettings.stickToGroundHelperDistance))
            {
                if (Mathf.Abs(Vector3.Angle(hitInfo.normal, Vector3.up)) < 85f)
                {
                    m_RigidBody.velocity = Vector3.ProjectOnPlane(m_RigidBody.velocity, hitInfo.normal);
                }
            }
        }


        private Vector2 GetInput()
        {
           
            Vector2 input = new Vector2
                {
                    x = CrossPlatformInputManager.GetAxis("Horizontal"),
                    y = CrossPlatformInputManager.GetAxis("Vertical")
                };
movementSettings.UpdateDesiredTargetSpeed(input);
            return input;
        }


        private void RotateView()
        {
            //avoids the mouse looking if the game is effectively paused
            if (Mathf.Abs(Time.timeScale) < float.Epsilon) return;

            // get the rotation before it's changed
            float oldYRotation = transform.eulerAngles.y;

            mouseLook.LookRotation (transform, cam.transform);

            if (m_IsGrounded || advancedSettings.airControl)
            {
                // Rotate the rigidbody velocity to match the new direction that the character is looking
                Quaternion velRotation = Quaternion.AngleAxis(transform.eulerAngles.y - oldYRotation, Vector3.up);
                m_RigidBody.velocity = velRotation*m_RigidBody.velocity;
            }
        }


        /// sphere cast down just beyond the bottom of the capsule to see if the capsule is colliding round the bottom
        private void GroundCheck()
        {
            m_PreviouslyGrounded = m_IsGrounded;
            RaycastHit hitInfo;
            if (Physics.SphereCast(transform.position, m_Capsule.radius, Vector3.down, out hitInfo,
                                   ((m_Capsule.height/2f) - m_Capsule.radius) + advancedSettings.groundCheckDistance))
            {
                m_IsGrounded = true;
                m_GroundContactNormal = hitInfo.normal;
            }
            else
            {
                m_IsGrounded = false;
                m_GroundContactNormal = Vector3.up;
            }
            if (!m_PreviouslyGrounded && m_IsGrounded && m_Jumping)
            {
                m_Jumping = false;
            }
        }
    }
}

37
Perfect.  Just what I was hoping for.  Thank you.

38
Hi,
When my character gets or spends money, I'd like the money display to quickly count up or down one coin at a time.  Is there a custom interpolate Int action that I can't find?  Or how would one do this?
Thank you!

39
Quote
Its already in the latest version.
What?!? <p=1.2> AMAZING!!!!!!  <p=2.2>  THANK YOU!!!!!!

Seriously,
Thank you so much!!

40
There is a wonderful action by Lane called String Typewriter.  It makes text appear one letter at a time for that old school - or Nintendo-ish text feel.

In my game, I'd LOVE to insert pauses in my text for emphasis.  Example:  "Look out for the //pause.2 MONSTER!!! //pause.4 Phew, //pause.1 that was close."  Lots of Nintendo games, like Animal Crossing, do this and it looks great.

Maybe if we could put a special code in the string, like //pause, then a time like .1, the action would know not to print "//pause", and would read it as a time wait command.

This is probably a big thing to ask help with... I'm not sure if it is even possible... but the results would be fantastic, so I thought I would ask.  Thoughts?  Thank you.

Here is the code for the current String TypeWriter.

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.

using HutongGames.PlayMakerEditor;
using UnityEditor;
using UnityEngine;

// You can't open an EditorWindow class in a C# Dll (as far as I can tell)
// So we use a wrapper script to create the window and hook the editor up
// TODO: move this to dll when Unity supports it...

namespace HutongGames.PlayMakerEditor
{
    [System.Serializable]
    class FsmEditorWindow : HutongGames.PlayMakerEditor.BaseEditorWindow
    {
        /// <summary>
        /// Open the Fsm Editor and optionally show the Welcome Screen
        /// </summary>
        public static void OpenWindow()
        {
            GetWindow<FsmEditorWindow>();

            if (EditorPrefs.GetBool(EditorPrefStrings.ShowWelcomeScreen, true))
            {
                GetWindow<PlayMakerWelcomeWindow>(true);
            }
        }

        /// <summary>
        /// Open the Fsm Editor and select an Fsm Component
        /// </summary>
        public static void OpenWindow(PlayMakerFSM fsmComponent)
        {
            OpenWindow();

            FsmEditor.SelectFsm(fsmComponent.Fsm);
        }

        /// <summary>
        /// Open the Fsm Editor and select an Fsm Component
        /// </summary>
        public static void OpenWindow(FsmTemplate fsmTemplate)
        {
            OpenWindow();

            FsmEditor.SelectFsm(fsmTemplate.fsm);
        }

        /// <summary>
        /// Is the Fsm Editor open?
        /// </summary>
        public static bool IsOpen()
        {
            return instance != null;
        }

        private static FsmEditorWindow instance;

        [SerializeField]
        private FsmEditor fsmEditor;

        // tool windows (can't open them inside dll)

[SerializeField] private FsmSelectorWindow fsmSelectorWindow;   
    [SerializeField] private FsmTemplateWindow fsmTemplateWindow;
    [SerializeField] private FsmStateWindow stateSelectorWindow;
    [SerializeField] private FsmActionWindow actionWindow;
    [SerializeField] private FsmErrorWindow errorWindow;
    [SerializeField] private FsmLogWindow logWindow;
    [SerializeField] private ContextToolWindow toolWindow;
    [SerializeField] private GlobalEventsWindow globalEventsWindow;
    [SerializeField] private GlobalVariablesWindow globalVariablesWindow;
    [SerializeField] private ReportWindow reportWindow;
    [SerializeField] private AboutWindow aboutWindow;

        // ReSharper disable UnusedMember.Local

        /// <summary>
        /// Delay initialization until first OnGUI to avoid interfering with runtime system intialization.
        /// </summary>
        public override void Initialize()
        {
            instance = this;

            if (fsmEditor == null)
            {
                fsmEditor = new FsmEditor();
            }

            fsmEditor.InitWindow(this);
            fsmEditor.OnEnable();
        }

        public override void DoGUI()
        {
            fsmEditor.OnGUI();

            /* Debug Repaint events
            if (Event.current.type == EventType.repaint)
            {
                Debug.Log("Repaint");
            }*/

            if (Event.current.type == EventType.ValidateCommand)
            {
                switch (Event.current.commandName)
                {
                    case "UndoRedoPerformed":
                    case "Cut":
                    case "Copy":
                    case "Paste":
                    case "SelectAll":
                        Event.current.Use();
                        break;
                }
            }

            if (Event.current.type == EventType.ExecuteCommand)
            {
                switch (Event.current.commandName)
                {
                    case "UndoRedoPerformed":
                        FsmEditor.UndoRedoPerformed();
                        break;

                    case "Cut":
                        FsmEditor.Cut();
                        break;

                    case "Copy":
                        FsmEditor.Copy();
                        break;

                    case "Paste":
                        FsmEditor.Paste();
                        break;

                    case "SelectAll":
                        FsmEditor.SelectAll();
                        break;

                    case "OpenWelcomeWindow":
                        GetWindow<PlayMakerWelcomeWindow>();
                        break;

                    case "OpenToolWindow":
                        toolWindow = GetWindow<ContextToolWindow>();
                        break;

                    case "OpenFsmSelectorWindow":
                        fsmSelectorWindow = GetWindow<FsmSelectorWindow>();
                        fsmSelectorWindow.ShowUtility();
                        break;

                    case "OpenFsmTemplateWindow":
                        fsmTemplateWindow = GetWindow<FsmTemplateWindow>();
                        break;

                    case "OpenStateSelectorWindow":
                        stateSelectorWindow = GetWindow<FsmStateWindow>();
                        break;

                    case "OpenActionWindow":
                        actionWindow = GetWindow<FsmActionWindow>();
                        break;

                    case "OpenGlobalEventsWindow":
                        globalEventsWindow = GetWindow<FsmEventsWindow>();
                        break;

                    case "OpenGlobalVariablesWindow":
                        globalVariablesWindow = GetWindow<FsmGlobalsWindow>();
                        break;

                    case "OpenErrorWindow":
                        errorWindow = GetWindow<FsmErrorWindow>();
                        break;

                    case "OpenFsmLogWindow":
                        logWindow = GetWindow<FsmLogWindow>();
                        break;

                    case "OpenAboutWindow":
                        aboutWindow = GetWindow<AboutWindow>();
                        break;

                    case "OpenReportWindow":
                        reportWindow = GetWindow<ReportWindow>();
                        break;

                    case "AddFsmComponent":
                        PlayMakerMainMenu.AddFsmToSelected();
                        break;

                    case "RepaintAll":
                        RepaintAllWindows();
                        break;

                    case "ChangeLanguage":
                        ResetWindowTitles();
                        break;
                }

                GUIUtility.ExitGUI();
            }
        }

        // called when you change editor language
        public void ResetWindowTitles()
        {
            if (toolWindow != null)
            {
                toolWindow.InitWindowTitle();
            }

            if (fsmSelectorWindow != null)
            {
                fsmSelectorWindow.InitWindowTitle();
            }

            if (stateSelectorWindow != null)
            {
                stateSelectorWindow.InitWindowTitle();
            }

            if (actionWindow != null)
            {
                actionWindow.InitWindowTitle();
            }

            if (globalEventsWindow != null)
            {
                globalEventsWindow.InitWindowTitle();
            }

            if (globalVariablesWindow != null)
            {
                globalVariablesWindow.InitWindowTitle();
            }

            if (errorWindow != null)
            {
                errorWindow.InitWindowTitle();
            }

            if (logWindow != null)
            {
                logWindow.InitWindowTitle();
            }

            if (reportWindow != null)
            {
                reportWindow.InitWindowTitle();
            }

            if (fsmTemplateWindow != null)
            {
                fsmTemplateWindow.InitWindowTitle();
            }
        }

        public void RepaintAllWindows()
        {
            if (toolWindow != null)
            {
                toolWindow.Repaint();
            }

            if (fsmSelectorWindow != null)
            {
                fsmSelectorWindow.Repaint();
            }

            if (stateSelectorWindow != null)
            {
                stateSelectorWindow.Repaint();
            }

            if (actionWindow != null)
            {
                actionWindow.Repaint();
            }

            if (globalEventsWindow != null)
            {
                globalEventsWindow.Repaint();
            }

            if (globalVariablesWindow != null)
            {
                globalVariablesWindow.Repaint();
            }

            if (errorWindow != null)
            {
                errorWindow.Repaint();
            }

            if (logWindow != null)
            {
                logWindow.Repaint();
            }

            if (reportWindow != null)
            {
                reportWindow.Repaint();
            }

            if (fsmTemplateWindow != null)
            {
                fsmTemplateWindow.Repaint();
            }

            Repaint();
        }

        private void Update()
        {
            if (Initialized && fsmEditor != null)
            {
                fsmEditor.Update();
            }
        }

        private void OnInspectorUpdate()
        {
            if (Initialized && fsmEditor != null)
            {
                fsmEditor.OnInspectorUpdate();
            }
        }

        private void OnFocus()
        {
            if (Initialized && fsmEditor != null)
            {
                fsmEditor.OnFocus();
            }
        }

        private void OnSelectionChange()
        {
            if (Initialized && fsmEditor != null)
            {
                fsmEditor.OnSelectionChange();
            }
        }

        private void OnHierarchyChange()
        {
            if (Initialized && fsmEditor != null)
            {
                fsmEditor.OnHierarchyChange();
            }
        }

        private void OnProjectChange()
        {
            if (Initialized && fsmEditor != null)
            {
                fsmEditor.OnProjectChange();
            }
        }

        private void OnDisable()
        {
            if (Initialized && fsmEditor != null)
            {
                fsmEditor.OnDisable();
            }

            instance = null;
        }

        private void OnDestroy()
        {
            if (toolWindow != null)
            {
                toolWindow.SafeClose();
            }

            if (fsmSelectorWindow != null)
            {
                fsmSelectorWindow.SafeClose();
            }

            if (fsmTemplateWindow != null)
            {
                fsmTemplateWindow.SafeClose();
            }

            if (stateSelectorWindow != null)
            {
                stateSelectorWindow.SafeClose();
            }

            if (actionWindow != null)
            {
                actionWindow.SafeClose();
            }

            if (globalVariablesWindow != null)
            {
                globalVariablesWindow.SafeClose();
            }

            if (globalEventsWindow != null)
            {
                globalEventsWindow.SafeClose();
            }

            if (errorWindow != null)
            {
                errorWindow.SafeClose();
            }

            if (logWindow != null)
            {
                logWindow.SafeClose();
            }

            if (reportWindow != null)
            {
                reportWindow.SafeClose();
            }

            if (aboutWindow != null)
            {
                aboutWindow.SafeClose();
            }

            if (Initialized && fsmEditor != null)
            {
                fsmEditor.OnDestroy();
            }
        }

        // ReSharper restore UnusedMember.Local
    }
}

41
Thank you.  It works!!!!!!!!!   ;D ;D ;D

42
Thank you for your time on this.
I've tried... but it is still not working.  Here is what I did:

1) I updated the code in SetStringValue.cs

Quote
[RequiredField]
      //[UIHint(UIHint.Variable)]
      [UIHint(UIHint.TextArea)]
      public FsmString stringVariable;
      [RequiredField]
      public FsmString stringValue;
      public bool everyFrame;

2) I have a GUI text.  (Of interest, in the Inspector Text Field, I can use carriage return and it works.  However, I need to be updating this text with Set String Value)

3) I then used Set String Value in the following ways:
/n
//n
\n
Copy/Paste from notepad with line breaks
Copy/Paste from word with line breaks
Copy/Paste from Inspector Text Field with line breaks

None resulted in line breaks or respecting carriage return, when using Set String Value.

I would love to be able use this function if possible.

Gratefully,
createasaurus

43
Hi,
I have a GUI Text that is updated with Set String Value.  I'd like to do a carriage return or line break, to do multipule lines.

I did a fourm search, and this topic has come up a lot.  There are many answers over the years (see below) none work for me now.  There are even some posts saying that the ones below no longer work.

1.) copy/paste from GUI text
2.) /n
3.) Open notepad, and copy/paste carriage return

Please, is there a current way to do this?  Should I keep trying these, perhaps I am I doing something wrong?

Thank you!!

44
PlayMaker Help / Re: Simplest way to have lots of text in game?
« on: September 17, 2015, 11:42:38 AM »
Hi djaydino and mdotstrange,

Thank you for the recommendations.  I will be checking these out - Array Maker and G2U.  My goal is to choose the simplest (to learn) path.

Thanks again,
createasaurus

45
PlayMaker Help / Simplest way to have lots of text in game? [Solved]
« on: September 16, 2015, 04:36:21 PM »
Hi,
My game has lots of NPCs, who I'd like to randomly say things.  Is there a best practice, or simplest way to approach this?  I know how to build this completely in PlayMaker where each character can randomly say 10 things... Then say 10 different things each time the story progresses... But doing this all in PlayMaker "coding" will get big and disorganized fast.  Is there a simple way to do this, where PlayMaker can access an excell file or something.  Just looking for general advice on how to approach this.  Thank you.

Pages: 1 2 [3] 4 5 ... 10