For the reels, I see that the static mesh is laying on it’s side by default (and that you’re needing to add 90 degrees in the BP editor) Best case scenario is for the reel to have the correct orientation/rotation with 0,0,0. (You can change this with the in-editor geometry tools now)
How do I go about doing this. All the meshes that I import in the engine are like that? I tried using the Modeling Mode > Transform > Xform, but after I apply and save when I import the mesh in the blueprint as a static mesh it still comes flat and I have to rotate it 90°
In the first screenshot of your last post I see that your interp speed is set to 0, this will cause an instant jump. (try numbers from .5 - 10 )
I tried this and it spins the reels in all directions still as a jump and no interpolation. Not sure if it is because of the Add rotation. Guess if I find a way to reset the original orientation I could use Set instead of Add and try that way.
General rule of thumb is that if you’re duplicating code/logic more than 2 times you should put it in a function. But 3 is only one more than two… so you could get away with copy-pasting the same logic without making too much of a mess. Although, be careful: If actively developing it could be a pain to change things in 3 spots.
Got it set up with functions and this should work fine if I figure out the rotation part.
Partial success… YAY!!! I was able to edit the mesh by rotating the pivot and resetting the Xform. Now the cylinder mesh stays at 90° but it’s at 0,0,0 in the world.
However, crazy shizznitz starts happening when I change the interp speed. I tried all int values between 1-10 and after a few clicks the reels start rotating on other axes… See below: (If I keep the speed at 0 it works ok, but no interpolation, just tick to the new value)
That last image of a ‘chaos slot machine’ is funny.
I’m getting lost in the back-and-forth, so apologies if I miss anything.
To back up quite a bit: with that project I sent you the wheels could spin in both directions. (Rinterps in the closest direction) - I think slots spin in only one direction? If spinning in one direction is a requirement I think that should be addressed before building ontop of it.
Glad to see use of print strings - you can change the color of the text to help keep track of which node it is.
I’m feeling like there is too much going on for me to easily troubleshoot.
If you really hit a wall. (There have been too many instances in this thread where you ask a question only to come back shortly after saying you’ve solved it) Sharing your project (File → Zip Project) would be an easy way to share the ‘full context’ (Just don’t include any marketplace assets)
Instead of getting all 3 wheels spinning, It might be a better approach to get one wheel spinning/stopping perfectly AND outputting the symbol it ends up on. (That way you figure the mechanisms out in a more controlled context)
My apologies for making it so messy. I am troubleshooting it almost every day, hence the solving of some issues.
To back up quite a bit: with that project I sent you the wheels could spin in both directions. (Rinterps in the closest direction) - I think slots spin in only one direction? If spinning in one direction is a requirement I think that should be addressed before building ontop of it.
True, I only want them to spin in one direction.
Instead of getting all 3 wheels spinning, It might be a better approach to get one wheel spinning/stopping perfectly AND outputting the symbol it ends up on. (That way you figure the mechanisms out in a more controlled context)
I agree, I think I got a little bit ahead of myself.
Can I pm you a link to the zip file?
Since spinning in one direction is a requirement, I don’t think looking at the zip and solving the chaos slot machine issue is important. (This could just resolve itself once the ‘spinning in one direction’ thing is figured out.)
If you were to ever share a zip, I’d ask you to do it publicly incase any other forum members wanted to hop in.
An idea to make that work with ‘RInterpTo’ : a way for it to reject+reroll values that would make it roll backwards. But I’d be leaning towards finding a way to use ‘Add rotation’. There’s also a ‘RotatingMovementComponent’ that can be added/controlled, but that applies to the entire BP, so a more ‘distributed’ (Each reel in a separate BP) approach would be needed.
Since spinning in one direction is a requirement, I don’t think looking at the zip and solving the chaos slot machine issue is important. (This could just resolve itself once the ‘spinning in one direction’ thing is figured out.)
Ok, I think I have figured out this part. This works as intended. The "Make Rotator, takes the random number generated and the “Add World Rotation” spins the reel to that amount. For each rotation, on click it continues with a new number from the previous. I have tested this by adding the numbers printed from each rotation, and by rotating the mesh in the viewport I get the exact same symbol. So this part seems to work ok.
Thank you so much for your patience… what am I doing wrong???
The second I plugged the timeline in… the numbers seem wrong. The rotation ends in-between symbols every 2-3 clicks or so.
If I bypass the timeline and the Ease functions the numbers are consistent and everything works fine.
If I leave the timeline plugged in but bypass the Ease function, it will output the same number, but the symbols don’t match at all with the actual rotation in viewport. Way off on every spin.
If I bypass the timeline and use only the Ease function with the Make Rotator, I’m getting numbers that are in between the symbols.
Am I doing something wrong or is there a better way of approaching this? I can’t figure this out for the life of me.
This works every single time, by adding the numbers to the previous rotation the symbols match exactly like when I manually rotate the reel in viewport.
Ah, I bet the ease function is ‘dampening’ the values which is causing the offset.
I’ve always imagined the rotation to happen in 2 stages, like where the first stage is completely random and once it’s “stopped on a symbol” is does another rotation pass to align all of them. (At this final stage I think a small ‘backwards’ rotation might look ok)
If you wanted to check the ease function you could set it to ‘linear’ and see what happens. But thinking about this more: The ease function is not necessary if you set a nice curve in the timeline. (The timeline just goes from values 0-1 over x seconds, so it’s possible to speed-up + slow-down portions of it with a curve)
To do this: Open up the timeline and select both of the points → Rightclick and choose ‘Auto’, you’ll see it pop from a straight line to a curved line.
The problem is that the timeline itself also messes up the final value. If I plug it in, it animates the spin and lands on a symbol. If I take the exact same random number and manually rotate the reel in the viewport it is a completely different symbol. It is waaaaay off… that’s why I’m stumped. No clue whatsoever why the output from timeline messes up the rotation. maybe I missed something inside the timeline?
My take on it so far… impossible to achieve this way. Timeline, Ease functions bug out everything. I’m assuming it’s either because of float <-> vector conversion internally (unlikely) or because it hits some sort of limitations for numbers > 360° (full turn). “Make Rotator” or “Lerp(Rotator)” on their own, work as intended, as long as no Timeline or Ease function is linked to them (even if the number is > 360°). But no type of animation, linked to that works (frustrating)
This was just an idea I had and in theory it should’ve worked beautifully.
Get a random number in the range of 60-150, multiply it with a delta (12) (so that it always ticks a multiple of the symbol length on the reel → 2-5 full spins) spin to that number and… Jackpot (pun intended)
I think this has to be done in a different way, by randomly spinning and making a nice animation and at the end somehow read the symbol from the final position.
P.s. Both animations, with Timeline and with Ease function, looked pretty bad (let alone the fact that they always messed up the outcome). There’s gotta be a better way.
I just had a crazy idea… kind of hacky but it could work…
Is it possible to dynamically set a float track for a timeline??? or access and modify the existing points on a float track dynamically? Meaning from outside the timeline and just pass those as variables for the timeline?
For the problem with the rotation in the timeline not matching up with what you’d get if rotating the object: My first guess is that it’s some sort of rounding thing, since there is a very small rotation value being added every frame.
For dynamically setting a float track in a timeline, there is some functionality around using/swapping curve assets. (But not sure how to dynamically generate curve assets)
~
As for a completely different idea: Use physics to spin the wheel. This should generate a nice blur, and then once you’ve decided on a random result, you could quickly rotate to the specific/correct rotation.
I just looked up this slot machine on the marketplace, and they mention using a ‘physics based’ approach.
Thanks for sticking with it! (and for being patient with me as I sometimes play ‘armchair-developer’ )
A physics based approach is easy to set up:
Enable Simulate physics on your mesh
Also in the Mesh details panel:
Constraints → Lock Location on all Axis, Lock Rotation on 2/3 axis. (the X vector is generally considered ‘forward’ in Unreal Engine, so looks like leaving Green/Y axis unlocked might be the way to go.)
There are several ‘Impulse’ nodes to use. (Angular impulse seems to make the most sense) - Sometimes these nodes like to use extremely large numbers for the impulse.
There is also a variable for ‘Angular Damping’ to be experimented with. (It’s also possible to set this variable at runtime for a possible ‘brake’ effect)
Thanks for sticking with it! (and for being patient with me as I sometimes play ‘armchair-developer’ )
Oh, I’m here for the long run
Thank you for actually replying to my noob questions and having the patience to guide me.
I think I will start from scratch and build 1 reel only. make that work as intended and then adjust.
Would this be an actor bp or pawn?
Also, the spin button should be a separate bp as well; Correct? Since later on, I’ll have to control all 3 reels from the same button.
I’m just trying to figure out the logic beforehand, so that I don’t run into other bp communication issues down the road.
Any tips on logic/functionality are greatly appreciated.
I do not want to just copy/paste the code from the marketplace asset.
I want to build this myself so that I understand everything.
Hope this makes sense.