I would like to be able to have a mesh’s orientation change depending on which component overlap is triggered.
Here is a video of what I would like to achieve:
If the dial is set to 0 and then the player steps on 45 > the dial will rotate to 45 over 2sec.
Then if the player is standing on 90 > the dial will rotate from 45 to 90 over 2sec.
If the player steps on 0 > the dial will rotate from 90 to 0 over 4sec.
Like that and so on. There will be more than 3 triggers, I will have a 8 triggers at 45degree increments. 0, 45, 90, 135, 180, 225, 270, 315.
It sort of works, but the problem is when I go to the next trigger (I want to go from 45-90), the animation will jump back to 0 and then rotate to 90. What I want is for it to start at whatever orientation it’s currently at, and then rotate to whichever orientation I trigger. Also the rotation speed should be constant no matter the rotation distance.
It seems like it should be pretty straightforward but I can’t seem to figure it out. Any help would be greatly appreciated.
I suggest to use tick for this. The idea is to define floats: CurrentAngle, TargetAngle, Speed. On tick, if CurrentAngle != TargetAngle add or deduct Min(Speed*DeltaTime, %actual-distance-to-target-angle%) from CurrentAngle depending on required rotation direction (which, depending on exact task, may vary). And ofcourse set your’s actor rotation to CurrentAngle.
Then each “overlap” you talking about should just set TargetAngle on your actor.
Timelines are not solution for generic problems like this, as they just return a set of hardcoded values from attached curves.
Thanks for the reply. Yeah On Component Overlap and Timelines are not necessary. It’s just the only thing I could think of. I watched several tutorials of things that I thought looked similar to what I wanted to do, like opening a door and moving a platform. So that’s where that idea came from.
Unfortunately I don’t know much about CurrentAngle, TargetAngle etc, and I can’t seem to find those nodes in Blueprint (i’m still learning more and more each day). If you don’t mind, could you send a screenshot of what you mean?
Also do I attach this to the timeline or do I leave in unconnected to anything? If I need to connect, does it matter if it goes before or after the timeline?
Thanks! That made it spin (also fixed the connection to Play from Start)! However rather than always rotating to the same spot each time, it’s just rotating by the value I added in the TargetRotation.
Think of it like a clock, if I want the hand to go to 3oclock it should go to 3, when I tell it to go to 6, it should go to 6, and so on. Does that make sense?
Great!!! This works! I think those nodes you added did the trick! However, the rotation speed is not constant. For example, if it take 5 seconds to rotate 45 degrees. It should take 10 seconds to rotate 90 degrees. Right now what is happening, is no matter how far it’s rotating, the time it takes to make that move remains the same.
It seems to be fine in my example, no? Rotating from 3rd to 1st is twice as fast, taking the same amount time as going from 1st to 2nd. Or am I really getting it all wrong.
Seeing now that more is needed that what was originally requested, I would have set up the whole thing slightly differently, to be honest.
Still, it’s a matter of remapping the rotation delta onto the TL playrate. You have only 1 and .5 speeds. You will need two (?) more speeds here, I guess.
Also, if you do not need it to last precisely X seconds, there are other ways as @Nawrot mentioned. Not only is there rInterp To, but also its rInterp to Constant equivalent.
I’m sorry for the confusion. I did however mention in my original post that I would have more stopping points on the circle and that I wanted a constant speed. I’m sorry my original message wasn’t clear. I appreciate the time that you and everyone else have taken to help me.
I made the changes that you mentioned in your screenshot and that does that trick! Thanks so much!!! If you don’t mind me asking, how long have you been working with Blueprints? Just trying to get a sense how long it might take to get as good as someone like you.
Oh, another question: I was looking again at your screenshot. Did you connect all of the Set Targets to the one Set Connect? If so, only one of the sets needs to connect to the Delta (Rotator)?
Haha. I would have loved to have seen how that over-engineered version would have looked. I probably would have thrown my computer out the window after seeing it. haha!