playMaker

Author Topic: Why is my Int Add doubling my number???  (Read 3353 times)

daniellogin

  • Full Member
  • ***
  • Posts: 215
Why is my Int Add doubling my number???
« on: October 26, 2018, 07:07:00 AM »
I'm doing a simply Int Add in a state with no other actions. It simply has the Variable with the number 1 written in.

Yet it's treating it like I said Variable + 2. No matter what number I use (and if it's negative or positive) it acts like I said twice as much.

So for example; my variable is 1 then I say 1 as the second number.... which produces the answer 3! Because it's doing 1 + 2 not 1+1.

WTF?

To debug things, I've tied skipping over the state which does the Int Add. This proved that I haven't forgotten I'm doing the same action somewhere else.
I have also tried switching the written in number 1 for a variable (set to 1) but it's exactly the same. It's still doubling my second input.
« Last Edit: October 26, 2018, 07:11:16 AM by daniellogin »

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Why is my Int Add doubling my number???
« Reply #1 on: October 26, 2018, 07:21:14 AM »
Ok more debugging says there is likely something wrong with a particular FSM.

I create a fresh FSM in a new gameobject doing exactly the same thing and it's working properly.

So what would cause and FSM to double actions? Is it just glitched out or something??

I actually already had a problem with this FSM. It was doing a simple Int Operator but hanging up on it with an loop count error. I couldn't figure out why so I just changed my logic to avoid the Int Operator. Seems though like the FSM wants to repeat itself some way or another.

I still haven't sorted this though. I tried making a new gameobject and copying, not the whole FSM as a component, but all of the states from one FSM into a new one. Same problem. Now I guess I will try to make a new one with no copying but get the feeling it will still go wrong.
« Last Edit: October 26, 2018, 07:35:18 AM by daniellogin »

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Why is my Int Add doubling my number???
« Reply #2 on: October 26, 2018, 08:24:09 AM »
This is so stupid. I'm thinking now it has to be a bug with Playmaker. I just updated it before this new project (last night) so maybe the latest version has a problem.

So how the hell does this latest observation make any rational sense:
I tried to debug if it has to do with a global variable by making it first set a local int from a global, then go on to it's steps of deducting (then checking if it's done or needs to keep deducting). This change means that the first deduction is correct. Eg; 5 - 1 = 4. But then it goes full retard. The next state checks if the (now local int) is equal to 0 or over. When it's over, it transitions back to an iTween movement then the deduction again. But this time, it goes 4 - 1 = 2. Then after cycling back it goes 2 - 1 = 0. I'm going to pull my F'ing hair out over this.

Why would the first cycle be fine then screw up after that??? What did converting to a local int have to do with anything but only fix the first run through Int Add???

I'm using a Send Event to go into this FSM. Is that relevant? I tried not transitioning back to the same state which has the global transition in it but that doesn't make any difference.

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Why is my Int Add doubling my number???
« Reply #3 on: October 26, 2018, 09:00:37 AM »
For anyone watching me talk to myself, I have (somewhat) solved my problem. I don't understand the WHY about it, but I've found what I would call a WORK AROUND.

So basically, I separated my Int Compare (to see if I need to move another square + deduct a dice roll tally) with a Wait action and the double deducting issue is gone. I want it to be fluid motion so although it's moving one square at a time the players just see it as moving all in one go, so I set the wait time to a tiny 0.001 realtime.

So yeah, no idea why I had to separate the Int Compare and the next iTween (or Int Add, as I tried both sequence orders) action.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Why is my Int Add doubling my number???
« Reply #4 on: October 26, 2018, 09:07:53 AM »
Hi.
Have you been using collaborate?

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
Re: Why is my Int Add doubling my number???
« Reply #5 on: October 26, 2018, 10:49:19 AM »
Hard to help without showing the FSMs, but you saying you need to separate two actions with a wait sounds like they're trying to run at the same time. Are the state set to action sequence?

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Why is my Int Add doubling my number???
« Reply #6 on: October 26, 2018, 01:37:23 PM »
Hi.
Have you been using collaborate?
No

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Why is my Int Add doubling my number???
« Reply #7 on: October 26, 2018, 01:47:42 PM »
Hard to help without showing the FSMs, but you saying you need to separate two actions with a wait sounds like they're trying to run at the same time. Are the state set to action sequence?
There isn't much to see. Also, while it may be hard to help without screenshots, it's hard to share them in this forum since you have to upload somewhere else and link to.

Here is what the setup is like:

* iTween move to | finish event = transition to next

* Int Add | "roll" add -1  (this is a 'dice roll' already determined and saved as a global int, which is counting down with each step forward on a board game) | transition to next

* Set Property (updates text mesh pro object to see where "roll" is up to) | transition to next

* Int Compare | int 1 "roll" compared to 0 | Equal = transition out (to irrelevant parts of FSM for this list) | Greater Than = transition back to the iTween at the top of this list

So as you can see from the above; not much to say. It's so basic. Yet the only way I could get it to work is to add one more state to Wait after the Int Compare to buffer between it and going back to the iTween (or the deduct. It didn't matter if I switched their order).
« Last Edit: October 26, 2018, 01:52:13 PM by daniellogin »

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
Re: Why is my Int Add doubling my number???
« Reply #8 on: October 26, 2018, 04:40:15 PM »
Quote
There isn't much to see. Also, while it may be hard to help without screenshots, it's hard to share them in this forum since you have to upload somewhere else and link to.
You mean like this?

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: Why is my Int Add doubling my number???
« Reply #9 on: October 26, 2018, 06:22:26 PM »
When the FSM returns a loop error, it means that somehow your int test doesn’t work, and it goes through the roof (or cellar in your case). Check the exact order and especially check where in the action list the events are sent. Everyone has this (self made) bug eventually, where you scratch your head why it doesn’t work, only to find out that an action is never executed, because another action above it redirects to a next state.

Next, check global events. They can also jumble up the routine in a single FSM, e.g. when a transition is called Foo, and you forgot you used it, and you send event Foo in a broad way (not specifying the target FSM) — that’s why global events should always stand out (mine are ALLCAPS for example).

Next, check the sequence. Did you swap the formula around (b minus a, instead of a minus b)? Does a variable need to be reset with each loop, and you forgot that? When the actions are in one state, and must be executed in exact sequence, did you set the state to sequence (right click on state)? Otherwise, the actions merely start in order, but can finish at different times (and out of order).

If it is a simple FSM, and you cannot figure out what goes wrong, but you can make a new one and this somehow works; maybe it’s better to just throw the broken one away, and move on with the working version. It’s good trying to find out what exactly went wrong, up to a point. ;)
« Last Edit: October 26, 2018, 06:29:11 PM by Thore »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Why is my Int Add doubling my number???
« Reply #10 on: October 26, 2018, 06:46:55 PM »
Hi.
You can use imgur ot upload images.
I'ts free and you can chose different sizes

Get the link and press on the top left image button (next to the globe)
then between the 2
Quote
place your url.

Showing images of your fsm/states/actions will increase the chance someone finds a solution, its well worth the 1 extra minute to add a picture.
if you want to show only parts from the screen you can use the snipping tool.
on imgur you can even paste it directly in.

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
Re: Why is my Int Add doubling my number???
« Reply #11 on: October 26, 2018, 08:21:59 PM »
I don't understand, why wouldn't one just attach the image in the post instead of uploading it somewhere external?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Why is my Int Add doubling my number???
« Reply #12 on: October 27, 2018, 06:18:56 AM »
Hi.
@DanielThomas

I prefer using external url because the attachment has a limit size of 512KB
also i can ad an image in between text lines.

When i use imgur and the snippet tool, i just do the snippet and go to the imgur page and press ctrl+v and its saved there.
No need to save locally.

But its just my preference, using the attachment is fine also :)

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Why is my Int Add doubling my number???
« Reply #13 on: October 27, 2018, 08:14:32 AM »
When the FSM returns a loop error.../
I moved on from the loop error, but wondered if it was somehow related. I deleted the states which caused that error so can't refer to it now, plus it's too confusing to mix the two different issues together now.

Quote
Next, check global events /... when a transition is called Foo, and you forgot you used it, and you send event Foo in a broad way .../
I don't think that is the issue. I mean firstly I don't see how a Wait added would change if two actual transitions are causing the issue. Second, I went through all the rest of my states (this project is still a very small game mechanics test at the moment) and couldn't see anywhere I accidentally doubled up or anything.

Quote
Next, check the sequence. Did you swap the formula around
No. I even did different numbers directly input and variables to see what was happening. The thing wasn't that it was being 'unpredictable' (like getting the answer -2 for the formula 5-3 (because it was entered 3 - 5), but was actually very predictably doing the wrong thing. It is very reliably doubling the number I put it. Not the variable, but the second integer.

Quote
Does a variable need to be reset with each loop
Don't know what you mean. But pretty sure no for a few reasons, once again including that a Wait wouldn't fix something like that

Quote
When the actions are in one state, and must be executed in exact sequence
No, not this either. Sometimes I actually create extra states just to avoid errors of sequence, but also so I can visually look at the FSM (without going in to states) and remember the steps and their sequences. It makes things bigger but easier to follow from a glance based on just the state names and not looking at the actual actions.

I'll attach images for the FSM here

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Why is my Int Add doubling my number???
« Reply #14 on: October 27, 2018, 08:17:30 AM »
Ok so here are some images attached. I didn't see the attach button before.

The images are named as FSM for the sequence, then the names of each state. It only lets me attach 4 at a time so see the next post for the last state picture.

« Last Edit: October 27, 2018, 08:20:09 AM by daniellogin »