playMaker

Author Topic: Float Clamp/Infinite Loop?  (Read 4472 times)

Gorotoro

  • Playmaker Newbie
  • *
  • Posts: 3
Float Clamp/Infinite Loop?
« on: January 03, 2014, 08:32:35 PM »
Hi everyone, I'm new here, and I searched for some answers for this question I have, but wasn't so lucky finding any.  Apologies in advance if this has been answered already.

I'm brand-new to Playmaker and Unity, and I'm working on a Breakout game I'm learning via a tutorial over at Skillshare.  Everything so far has been working for me just fine, but when I try to set a limit to horizontal movement of the paddle, using Float Clamp and Set Position, the paddle gets stuck, and I have to restart the game.

I'm not sure what I'm doing wrong, as I've followed the directions very closely as provided in the tutorial, and for all intents and purposes, it should be working.  Here's a screenshot to give you an idea of what I'm doing:



Sorry if there's not enough information provided, but I can put more up if this too confusing.  Thanks in advance!

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: Float Clamp/Infinite Loop?
« Reply #1 on: January 03, 2014, 11:32:31 PM »
I've create a quick setup, and it is working.

Only using 1 state, without transition...basically I created two variables, one called x_axis, and the other is x_pos.
Using get axis, I've added to the x_axis variable, and then using float operator x_axis value is added to x_pos variable and store it to x_pos again, below float operator, I've added float clamp, and chose x_pos variable with a min and max value, finally I've set the position using x_pos variable...

here is the screenshot of it (hope this helps):

PlayU

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Float Clamp/Infinite Loop?
« Reply #2 on: August 06, 2014, 09:38:02 PM »
Cloud03's method hasn't worked for me either.  Any other ideas?

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: Float Clamp/Infinite Loop?
« Reply #3 on: August 07, 2014, 10:24:11 PM »
Here I attached a working sample of mine...please let me know if you need any help.... :)

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Float Clamp/Infinite Loop?
« Reply #4 on: August 07, 2014, 11:47:51 PM »
A general strategy when you create an unintended infinite loop is to use Next Frame Event. E.g., Use it on your Reset X state to send the FINISHED event in the next frame (instead of immediately).

Or do the work in a single state as in cloud03's example.

PlayU

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Float Clamp/Infinite Loop?
« Reply #5 on: November 13, 2014, 01:14:30 PM »
Ok thanks

Aldous00

  • Playmaker Newbie
  • *
  • Posts: 1
Re: Float Clamp/Infinite Loop?
« Reply #6 on: June 22, 2020, 09:07:37 PM »
Cloud03 - your method just helped me out, thank you for sharing the screenshot!!!!

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: Float Clamp/Infinite Loop?
« Reply #7 on: June 23, 2020, 07:56:18 AM »
Aldous00: Glad it helps  :)