I came up with a slightly different solution that results in my door revolving constantly if I set the InitialYaw to above ~130 degrees. Anyone have any ideas as to why?
Iāve edited your post to use a code block, please do that in the future.
GetActorRotation returns a value between -180 and 180 so if itās at 130 and then do +90 that would go to 220 which is unreachable.
You could use GetDenormalized() on the FRotator so it has a value of 0-360 but youāll run into similar ssues with different rotations.
The easiest way to solve this is to use SetRelativeRotation on the static mesh. So you would have an actor with a scene component which will be used to for the rotations to be relative to as SetRelativeRotation is based off of the root component e.g.
Thanks for replying so fast. I now understand why it happened (thanks again), but Iām struggling to understand your solution. Iām not sure what you mean by āscene componentā. I donāt know what āwhich will be used to for the rotations to be relative toā means or how to āuseā SetRelativeRotation on the static mesh (a static mesh is just the model or frame that textures go onto, right?), Iāve never seen/used ā|ā before. Sometimes I struggle to fully grasp some of the concepts in the lectures, have I done that here?
A SceneComponent has a transform and supports attachment, but has no rendering or collision capabilities. Useful as a ādummyā component in the hierarchy to offset others.
That half explains it. So if that component is the root, and the door mesh is a child of that then if you were to do +90 SetRelativeRotation on the door mesh it would always open 90 outwards as itās relative to the root component.
Say you rotate the door in your scene to be (0, 270, 0) that would be the rotation of your root component. So with the static mesh as a child of that you can say rotate +90 relative to that.
How have you been getting components so far?
Not really. I tend to be a bit vague on purpose as a lot of people like figuring things out themselves and I donāt want to rob people of that by just going āhereās the full solutionā.
So I start off with general advice on how to go about something and gauge on how much direction and guidence is needed based on replies.
Start off by dragging an Empty Actor into your world and then add a static mesh component to it
Just tried to have one of the initial yaw =140ā¦
and used GetOwner()->SetActorRotation(DoorRotation);
and it worked as it is supposed to be when i set the target to 90 . Are you sure about the 180 limit ??? Because when the door is fully open the Current Yaw shows 230 as it is supposed to be;
This is the partial code i used in TickComponent.() function which is similar to Mikeās
Iām saying that GetActorRotation only returns values within that range. Not that you canāt pass in an FRotator with values outside of that to SetActorRotation.
ok. now looking into it more detailed ā¦so GetActorRotation() normalizes the values , and that is why you mentioned about using GetDenormalized() on FRotator; makes sense now Thanks ā¦that is very good information indeed.
But I believe his issue is because of updating the CurrentYaw() with the GetActorRotation() rather than Lerp() to FInterpTo() function. That is the difference in mine and it gets me the right value to rotate rather than Normalized().
Another issue I noticed (I was originally doing)
if we set SetActorRotation({0.0f, CurrentYaw, 0.0f});
then this might give some unexpected results in the future for different cases because while we are updating yaw value we are also setting the other axises to zeroand if they are not then it might be issue.
Not on this one because the other axis rotations are already zero so I think interfacewise the solution that Mike used is a good one or the one you suggested with using Parent - Child relation and SetRelativeRotation(). Maybe DoorFrame being the parent since the door is attached to it . But I could never think of the empty actor way you describedā¦
I tried that Parent - Child relation with the DoorFrame ->Door but I think I messed up since I was not sureā¦how to access values. I believe we are gonna cover those in the upcoming sectionsā¦