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 - Guavaman

Pages: 1 [2] 3
16
General Discussion / Re: Rewired/Cinemachine Actions discussion
« on: July 30, 2018, 09:59:56 AM »
I won't be making an Action to replicate what GetAxisVector does. Rewired provides input. It does not provide in interpretation/use of that input. IE: transforming input into other spaces, moving objects, etc. That is beyond the scope of the system. It would quickly snowball into a gigantic monster with an infinite number of expected actions/methods for every different use case everyone has.

The proper way to do something like this is to separate the "getting the input value" and "transforming the input value" into two separate actions. Then you simply get the input, store it in a variable, then transform the input and apply it to whatever you want to apply it to.

Thanks Guavaman,

How about Cinemachine Free look Cam? Any tips on how I could override Input controllers there with the current actions provided or would that require some custom code?

Jean's post shows what you need. Here's a more simplified version:

(code removed)

17
General Discussion / Re: Rewired/Cinemachine Actions discussion
« on: July 30, 2018, 09:31:38 AM »
I also cannot get the proper usage of Get Axis Vector for movement relative to camera position.

This is a simple and very common transformation operation:

Code: [Select]
// Transform from camera space to world space
Vector3 worldSpaceMoveVector = Camera.main.transform.TransformDirection(inputVector);

// Apply deltaTime and speed
worldSpaceMoveVector *= Time.deltaTime * speed;

// Move the object in world space
target.Translate(worldSpaceMoveVector, Space.World);

You should be able to easily do the same using PlayMaker actions.

18
General Discussion / Re: Rewired/Cinemachine Actions discussion
« on: July 30, 2018, 01:00:58 AM »
I won't be making an Action to replicate what GetAxisVector does. Rewired provides input. It does not provide in interpretation/use of that input. IE: transforming input into other spaces, moving objects, etc. That is beyond the scope of the system. It would quickly snowball into a gigantic monster with an infinite number of expected actions/methods for every different use case everyone has.

The proper way to do something like this is to separate the "getting the input value" and "transforming the input value" into two separate actions. Then you simply get the input, store it in a variable, then transform the input and apply it to whatever you want to apply it to.

19
Feature Requests / Re: enum flags and FsmLayerMask?
« on: June 29, 2018, 09:39:20 PM »
Was the flags/bitmask feature ever added for enums?

20
PlayMaker Help / Re: Using Playmaker with Rewired
« on: November 17, 2017, 07:21:56 PM »
Hi guys,

Just started using Rewired. I want to use Xbox and PlayStation controllers in my Windows game, I have set up a Dual Analogue Gamepad map using Rewired Editor.

I have defined all the keyboard and mouse commands in FSM's on my character previously. Can I, and which actions can I use (Rewired integration is done and relevant actions are available), to hook up those commands to that Rewired joystick map? Or is it done otherwise?  :)

The very first thing you should do is read the documentation. This documentation applies whether or not your're using PlayMaker. You need to understand the concepts about setting up your input configuration first. Even after that, all the documentation still applies. PlayMaker's Actions are nothing more than wrappers around the equivalent Rewired functions. For example, in code, to get input for "Move Horizontal", you type:

player.GetAxis("MoveHorizontal");

In PlayMaker, you use the RewiredPlayerGetAxis Action and set the value of the Action you want to "MoveHorizontal".

They are functionally equivalent. Nearly the entire Rewired API is the same way.

Getting input is covered here: http://guavaman.com/projects/rewired/docs/HowTos.html#get-input

Rewired will provide you the raw input values you need (button presses, axis values, etc.), but it will not apply these input values to your character / cursor / whatever object you're moving. That would be beyond the scope of the system. Any PlayMaker Actions that exist to move characters, etc. that can read an external variable (Vector2, float, boolean, etc.) will work with Rewired because you just store the resulting action's value as a variable and have your other PM Action read that variable. There are also events on some of the Actions like RewiredPlayerGetButtonDown where you can use the Is True event to then branch to some other PM Action.

21
PlayMaker Help / Re: Storing non mono-behaviour object as variables[SOLVED]
« on: September 26, 2016, 11:23:48 AM »
Hi,

 I would propose a solution that I use for XmlMaker ( same problem).

create a wrapper that reference your object using a string as key, just like variables do, only that you write the system yourself.

so create a static hashtable or dictionnary of string-> object and get set your object using the string key as a reference.

Does that make sense?

else, like ngui and Unity UI do, you could create a GameObject per Object and a monobehaviour on that object would be the interface for you to communicate with it.

Bye,

 Jean

Hi,

Thanks for the reply!

I've tried both the wrapper approach using a class that inherits from ScriptableObject as a wrapper, and the hashtable/dictionary approach using a Dictionary<int, object> that stores the object reference and assigns it a unique id. The problem with both approaches is that these objects stay in memory forever unless the user manually clears them with some Action such as FreeObject.

If the user stores an arbitrary object in a variable, and this variable is a hash or unique id that points to the static object manager, the static object manager retains an object reference to this object forever unless manually removed when the user is finished with the object. It cannot be automatically deleted as far as I know because the user may store this value in a variable anywhere in any or multiple FSMs.

The wrapper approach has the same problem -- the SerializedObject must be cleared with Object.Destroy when the user is finished or it will stay in memory forever.

The more objects that are added to the object manager or the more SerializedObject wrappers that are created, the more memory will expand.

How do you deal with this issue with your XML Maker Actions? Do you ever clear the objects in your static class or are the left there forever?

The only way I can think of to automatically garbage collect these objects would be to check all variables in all globals and all FSMs and check if a unique id is no longer in use before clearing it. (I imagine that process could take a very long time.) Edit: No, this approach won't work either because there would be no way to detect which variables are just normal ints and which ones are ints that store a uid key for an object.

For non-serialized objects, it seems it would be easy enough to have an FSMNonSerializedObject or another field in FSMVar to handle System.Object classes that do not need to be serialized along with an associated VariableType.NonSerializedObject to store these references during runtime as a System.Object field. These obviously could not be set by drag-and-drop and would not be editable by the user in the editor (that's not their purpose), but it could be used by Actions for runtime APIs that need the ability to pass around arbitrary objects to an API.

22
PlayMaker Help / Re: Storing non mono-behaviour object as variables[SOLVED]
« on: September 26, 2016, 12:51:35 AM »
Have there been any changes to this limitation since this post? I can't find any recent information on this issue.

I've tried both object wrappers that inherit from SerializedObject and creating an object manager that stores a Dictionary of unique ids. Both of these approaches have the same issue -- created objects or object references must be freed manually by the user or memory will expand indefinitely. The wrapper approach using SerializedObject requires that Object.Destroy be called when the object is no longer required. The object manager approach requires that the object be deleted from the object manager when it's no longer required. Both approaches require that the user learn about and perform data management which is not something I think most users would be happy about.

For my purposes, the objects in question do not need to be serialized and do not need to persist between sessions. They are runtime-only objects which must be able to be passed around to various parts of an API. They need to be able to be stored in an array, the array iterated, and various tasks performed with the objects.

I haven't been able to come up with an acceptable general-purpose solution to this issue. Does anyone have any ideas?

23
I don't get an infinite loop when I test with those repro steps.

Do you have a FINISHED event back from the second state to the first state. That would cause an infinite loop...

Thanks for the response. I guess I didn't have email notifications enabled.

I see what you are saying. If State 1 is ever entered again on the same frame, the GetButtonDown value will still be true and will set off an infinite loop. I posted this based on a bug report I received from a Rewired user who ran into this issue with my GetButtonDown Actions. I don't know exactly how the user was using it, but I would say it was almost certain that they were returning to the original State within the same frame to cause this infinite loop.

I see your included Input.GetButtonDown Actions do not evaluate OnEnter and always OnUpdate so they do not have this issue and cannot be re-evaluated during the same frame. I guess this would be the more appropriate way to handle input state checking.

24
This doesn't seem to make much sense to me. An Action's OnEnter gets fired every time an Fsm.Event is called causing infinite loops if you ever fire an event from within OnEnter.

Take this example:

Code: [Select]
public class TestAction : FsmStateAction {

        public bool everyFrame = true;
        public FsmEvent onTrueEvent;

        public override void Reset() {
            base.Reset();
        }

        public override void OnEnter() {
            DoUpdate(); // this will cause an infinite loop because onTrueEvent will be fired from within OnEnter, then OnEnter will run again, over and over...
            if(!everyFrame) Finish();
        }

        public override void OnUpdate() {
            DoUpdate();
        }

        public void DoUpdate() {

            // Just fire when X is pressed for testing
            if(Input.GetKeyDown(KeyCode.X)) {
                // Fire event
                if(onTrueEvent != null) Fsm.Event(onTrueEvent);
            }
        }
    }

  • Add the TestAction to the default FSM state.
  • Add a Finished event and a new state.
  • Connect the Finished event to the new state.
  • Set the onTrueEvent to Finished in the inspector.
  • Press Play.
  • Hit X to fire the event.

Result:
GameObject : FSM : Loop count exceeded maximum: 1000 Default is 1000. Override in Fsm Inspector.

Adding some debug logging reveals that for every time the onTrueEvent is fired, OnEnter is run again, causing onTrueEvent to be fired again, then OnEnter to run again, etc.

Is this behavior intentional? It doesn't make sense to me that firing an event that should initiate the transition to the next state should then cause the same calling FSM state to be entered again and OnEnter to be called on the Actions.

25
Share New Actions / Re: Rewired (polling) Actions
« on: November 24, 2015, 08:31:45 PM »
oh god, starting to feel so dumb. i really dont want to do that plan, i had the naive idea that it would be just a matter of changing a variable or something and then saving it as a new action so it would be seperate from the original Get Axis Vector. i do use the Rewired actions you made and they are great, i guess this is just me trying to figure out how achieve something i'd managed to do before i got Rewired.

so now i think in theory, i should be able to do the exact same thing by using Rewired Player Get Axis, for both axis. then put that input into Get Position, which takes float variables and puts them both into a vector3 variable. is that the same as Get Axis Vector? im not at home now, so i will have to try it later

I don't know exactly what you're trying to achieve, but Rewired has Actions for both GetAxis and GetAxis2D. GetAxis returns a float from -1 to 1 and GetAxis2D returns a Vector2 between -1, -1 and 1, 1.

Directly putting joystick axes into a transform position vector isn't going to work. You'd just be setting the position to a range between -1 and +1 on one or all axes.

26
Share New Actions / Re: Rewired (polling) Actions
« on: November 24, 2015, 01:15:28 PM »
would anyone know how i could change an existing action that gets input from unity input manager to take input from rewired? i need the playmaker action Get Axis Vector to accept Rewired "actions".

This does not sound like the right approach. You're essentially trying to turn the default input Actions into the Rewired Actions. Why? So you don't have to replace the Actions in your FSMs with the Rewired versions? This is not a good idea for many reasons, for example you won't be able to update Playmaker without overwriting your changes.

If you _really_ want to do this, you're going to have to make a lot of changes to the input Actions so they take the variables Rewired needs and call the Rewired methods. If you don't know C# well or how to write custom Actions, this is going to be a difficult task for you.

27
Share New Actions / Re: Rewired (polling) Actions
« on: October 11, 2015, 05:55:01 PM »
Rewired 1.0.0.70 is now live on the Unity Asset Store and includes a PlayMaker integration pack which you can install from the menu.

28
Share New Actions / Re: Rewired (polling) Actions
« on: September 28, 2015, 11:53:20 PM »
 :)

29
Share New Actions / Re: Rewired (polling) Actions
« on: September 28, 2015, 09:53:40 PM »
Rewired's next release includes PlayMaker actions for a variety of tasks. The announcement and instructions on how to get early access to updates can be found here: http://forum.unity3d.com/threads/rewired-advanced-input-for-unity.270693/page-24#post-2316433

The new actions also allow you to directly fire events based on input without having to store the value in a variable first.

30
Share New Actions / Re: Rewired (polling) Actions
« on: September 12, 2015, 11:18:54 PM »
Care to shed some light?  I am really at a loss on how to make the play maker actions send events etc.  Rewired looks amazing but I just don't get how to make it work.

Create a variable to fill with the value from the Rewired PM action (GetButton, GetButtonDown, GetAxis, etc). Add the Rewired PM action to the FSM. In the Value field, click the box to the right and choose your variable from the dropdown. Now the variable will be populated by the Rewired polling event. Enter the Action Name for the Rewired Action you want to watch, then click Every Frame to make it update the value each frame. Now you have a variable that contains the button state / axis value. Just use a logic test (bool test for buttons, float for axes) to do something with that value.

Disclaimer: I didn't make these actions and I am by no means a PlayMaker expert so I cannot give you advice on best practices. The only time I've ever used PlayMaker was to make a set of actions for another of my asset store tools.

Pages: 1 [2] 3