XY Pad Modulation
-
Figured I should start a new thread instead of hijacking the CUBE one :)
I'm working on a modulation system for the XY Pad using Timers, and I can get it to go from 0 to 1 on an axis, then change directions once it reaches 1, but it's using an if statement to check if the current value is less than the "destination" value, so the instant it swaps directions and goes back to <1, it changes directions to positive again and gets stuck in a loop
example gif: https://i.gyazo.com/db19c1d398f82935a38cdee71cf5eb4e.mp4
chaosXDrift.setTimerCallback(function() { if (Slider_MovementXInvisible.getValue() < chaosXTarget) { Slider_MovementXInvisible.setValue(Slider_MovementXInvisible.getValue() + 0.1); Console.print("Going Up"); } else { Slider_MovementXInvisible.setValue(Slider_MovementXInvisible.getValue() - 0.1); Console.print("Going Down"); } Panel_MovementXYPad.repaint(); });
I just want a simple "sine" movement but I can't wrap my brain around the best approach for the logic, any help is appreciated :)
-
@iamlamprey said in XY Pad Modulation:
Not sure exactly what you are trying to do but wouldnt this work?
reg dirSet = 0.1; chaosXDrift.setTimerCallback(function() { if (Slider_MovementXInvisible.getValue() < 0.1) { dirSet = 0.1; } if (Slider_MovementXInvisible.getValue() > chaosXTarget) { dirSet = -0.1; } Slider_MovementXInvisible.setValue(Slider_MovementXInvisible.getValue() + dirSet); Panel_MovementXYPad.repaint(); });
-
@Lindon Yeh that does the same thing as my current script, the idea is:
- Engine sets a "destination" XY coord
- Timer checks if X and Y position are equal to, less than or greater than the destination
- Timer either makes a new destination coord, adds 0.01 or subtracts 0.01 respectively
It's like the timer isn't calling the new coordinate thing, even though i have console.print printing out both values and they do in fact match...
-
Every time they both equal 0.86, it should "reroll" the target, but it's not, could that have something to do with deferred callbacks or something? Or variable scope?
-
Is there a way to reduce the number of decimal points from Math.random() ?
-
Ok got it working :) I had to change all of my values to integers since the rounding was causing some issues
-
hey @iamlamprey do you recall what number range you used when you did this? im trying to make it work with knobs that go from 0.0 - 1.0. I changed the knob to have a range of 0-100 but it reads 1000% instead lol. i know that im doing something wrong..
-
@Adam_G I don't remember off heart but the source for the XY pad I used is here:
https://github.com/nytemairqt/NEATplayer/blob/master/Scripts/MovementSettings.js
-
@iamlamprey thanks for replying. checking that out and looks like they used decimals too. am i reading that right?
Movement_Xpos = Math.range(Slider_MovementXInvisible.getValue() / 100, 0.03, 0.97);
-
@Adam_G hmm, i just opened the project and apparently the sliders that control the XY pad go from 0.0 to 100.0, the actual XY values i believe are 0.0 - 1.0
it's been a while since I've opened this project so its a bit hazy sorry, been working on other things
-
@iamlamprey thats definitely a hint haha, thanks again :) ill keep trying
-
I made a couple of videos all about XY pads. Currently they're only available to Patrons.