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

Pages: 1 [2]
PlayMaker Help / Re: Int Operator, please help
« on: February 12, 2015, 09:23:35 AM »
Thanks Lane,

Something like that would be great, the key to my project is that every button has a different effect upon the object and when two or three buttons are pressed another effect is spawned. so each int value created through the Int operator with then spawn an individual action from the Int switch,

I am so close with the tools that are there, I just need to get Int compare to work with more than two variable.

I had a go at the code but I am certainly no expert!

// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
   [Tooltip("Performs math operation on 2 Integers: Add, Subtract, Multiply, Divide, Min, Max.")]
   public class IntOperator : FsmStateAction
      public enum Operation

      public FsmInt integer1;
      public FsmInt integer2;
      public FsmInt integer3;
      public FsmInt integer4;
      public Operation operation = Operation.Add;
      public FsmInt storeResult;
      public bool everyFrame;

      public override void Reset()
         integer1 = null;
         integer2 = null;
         integer3 = null;
         integer4 = null;
         operation = Operation.Add;
         storeResult = null;
         everyFrame = false;
      public override void OnEnter()
         if (!everyFrame)
      // NOTE: very frame rate dependent!
      public override void OnUpdate()
      void DoIntOperator()
         int v1 = integer1.Value;
         int v2 = integer2.Value;
         int v3 = integer2.Value;
         int v4 = integer2.Value;

         switch (operation)
            case Operation.Add:
               storeResult.Value = v1 + v2 + v3 + v4;

            case Operation.Subtract:
               storeResult.Value = v1 - v2 - v3 - v4;

            case Operation.Multiply:
               storeResult.Value = v1 * v2 * v3 * v4;

            case Operation.Divide:
            storeResult.Value = v1 / v2 / v3 / v4;

            case Operation.Min:
               storeResult.Value = Mathf.Min(v1, v2, v3, v4);

            case Operation.Max:
               storeResult.Value = Mathf.Max(v1, v2, v3, v4);

it seems to run fine but when I debug it just fires back a 0 for any value going through the third or fourth variable.

Thanks again,


PlayMaker Help / Int Operator, please help
« on: February 12, 2015, 08:53:24 AM »
Hi all.

I have been using playmaker for a while now and it has been great, so much faster than struggling through scripts.

But now I need a little bit of help,  I will try and explain what it is that I am trying to achieve, any advice would be greatly appreciated.

I am trying to use multiple buttons to interact with the same object. for example if button 1 is pressed the object material is changed to blue, button 2 = yellow... so far so simple the complex bit is registering actions from both buttons to change the material green thus having a third state or fourth or fifth etc.

I have approached this by creating fsm's on each object that simply register input and send a global event to a controller fsm,  each input eg blue pushed i then assign a int value, eg blue pushed or yellow pushed, which reverts to 0 ones the the button is released, I then use Int operator to add the values from the int variable and store in a 3td variable that I use in and Int switch.  This work great with 2 variable's as this is what the Int operator naturally work with, but not with a 3rd, 4th etc.

I have attempted to modify the Int Operator.cs to enable multiple int values to be compared, the floats appear within the playmaker state but always returns a 0 int value. 

ps there are no errors in my scene,

Any assistance would be most gratefully received,

Cheers  :)

Pages: 1 [2]