playMaker

Author Topic: [SOLVED]Int Compare not working  (Read 3488 times)

AxelG

  • Playmaker Newbie
  • *
  • Posts: 34
[SOLVED]Int Compare not working
« on: November 17, 2019, 10:45:14 PM »
Hello,

I'm trying to compare an "animated" int to a regular one with an int compare action and I can't make it work.
The action automatically goes to the next event whatever the value is.

Screenshot attached.

Is my setup wrong?

Note: The goal here is to define when a video is finished, I'm using a VideoPlayer get time converted float to int compared to a VideoLenght float converted to int.
« Last Edit: November 20, 2019, 10:37:46 AM by AxelG »

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Int Compare not working
« Reply #1 on: November 18, 2019, 12:33:51 AM »
Hi, try not using the built-in finished event. Make your own event to use in this action. Built-in Finished events typically fire right away.

AxelG

  • Playmaker Newbie
  • *
  • Posts: 34
Re: Int Compare not working
« Reply #2 on: November 18, 2019, 01:26:44 AM »
Hi Tcmeric,
I tried with an other event and I had the same issue, thanks for the tips anyway.

ch1ky3n

  • Full Member
  • ***
  • Posts: 208
Re: Int Compare not working
« Reply #3 on: November 18, 2019, 06:45:32 AM »
hey Axel, are you familiar with the debug?

whenever you have a problem, try to debug it
you can do it by

1. Rightclick on your state and toggle breakpoint it
2. then hit Play, it will pause on the state where you enabled the "BreakPoint"
3. Finally, you can check the flows, the variables and why they send you to particular events.
4. try to toggle as many breakpoints in your state as possible to better analyze the problem.
5. It will make the game goes frame by frame and you can move on to the next frame by clicking on the >> button near the play button(The fast forward button)
6. while doing it, check your state flows and try to figure it out why

hope it will helps
« Last Edit: November 18, 2019, 06:47:24 AM by ch1ky3n »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Int Compare not working
« Reply #4 on: November 18, 2019, 07:54:41 AM »
Hi.
you have an event for all conditions, then Every frame is not needed.
in your setup you might get loop error as well.

Can you show what you are doing in the 'Get Next Event' State?

I think it can be simplified by having the int compare in 1 state together with what you have in the 'Get Next Event' State.

And only set an event for equal and greater (leave lesser than empty)

AxelG

  • Playmaker Newbie
  • *
  • Posts: 34
Re: Int Compare not working
« Reply #5 on: November 18, 2019, 06:39:33 PM »
@Chyky3n: Thank you. I wasn't familiar with the "toogle breakpoint" but it helped me solve this problem.

The problem was that at the moment the FSM starts, the compared variables values weren't stored yet, so it was both "0" so equal that caused the instant switch to the next event.
I added a "Wait" action of 1s since all videos will be longer than 1 second.

@djaydino I've attached a screen with my next event state, it is a Next Frame event to avoid loop errors, saw one of your video about it (thanks), is it correctly set up?
I think I must have the "every frame" ticked because when I disable it, even with everything on a different state, the software doesn't detect when the int values are equal.
Maybe I am misusing it?


Also: Is there a way to check for a boolean value and define an event depending on it? I've seen the "bool test" action is that its main purpose or is there something else?
« Last Edit: November 18, 2019, 06:44:02 PM by AxelG »

ch1ky3n

  • Full Member
  • ***
  • Posts: 208
Re: Int Compare not working
« Reply #6 on: November 18, 2019, 11:41:15 PM »
Instead of using state only contains next frame, you should emptied the less condition (remove the loop event)

It is like

If it is higher go to room A
If it is less go to room b doing nothing and back <<< this doesnt make any sense

You simply say if it is higher or equal go to room A
No need to mention lesser because it is irrelevant / doing nothing / keep staying in room B

Edit: DjayDino said it first that you should emptied the less condition.
« Last Edit: November 18, 2019, 11:52:17 PM by ch1ky3n »

ransomink

  • Playmaker Newbie
  • *
  • Posts: 44
Re: Int Compare not working
« Reply #7 on: November 19, 2019, 12:19:41 PM »
Also, why convert both float times to an int just to compare? It'd be easier and more accurate if you kept the float values and used Float Compare action instead...

AxelG

  • Playmaker Newbie
  • *
  • Posts: 34
Re: Int Compare not working
« Reply #8 on: November 20, 2019, 10:37:28 AM »
@ch1ky3n: I removed the less condition and deleted the loop event.
The screenshot was before I made any modification :)

@ransomink: I can't let the float because I noticed that when the video ends, the value for a "10,00333"seconds video is "10" seconds so when I'm comparing it will never reach the real video duration. I loose some precision but not impacting what I wanted to do.

Problem solved anyway, thank you all.
Axel