Bug found when using rotateLocal()

I tried it and saw nothing unexpected. The capsule always rotates back into position. What is it that you are seeing that makes you think an event is sticking?

In that case, when you set the angles on the entity, the engine has to apply it to the entity’s transformation matrix. When you get the euler angles again, it has to calculate them from the matrix so it won’t be exactly the same value that you have set.

I also recommend against checking against localEulerAngles as they can flip when one axis is more than 90 or less than -90. I you are constantly setting the rotation via euler angles, I would keep a local set in the script and apply it to the entity every frame. It’s a lot easier to control and check bounds.

1 Like

Got it. So a calculation is being done and it isn’t as simple as setting a variable. Just to confirm (of course), I put a console statement in the initialize section to read the x value for the capsule before the user can input anything and it returned -90.00000000000003. So even though the Editor has the value set for 90, the actual value is slightly different. That is also the same value I’m currently getting from the console when I set the Euler angle to 90 via an action in the script. So that’s nice and consistent. The only thing that bugs me now is why I was getting -89.99999999999999 before - but that will have to remain a very minor mystery for now.

So the upshot is that I’ll need to test for “rounded” values. In fact, if I have to round the values anyway, for Euler angles at least, there’s no real need to try to manually set the Euler angle to the desired whole number. I can just directly test for a rounded value of where the rotation lands.

Thanks for bearing with me.

Hey @yaustar i have a quick question. I want my game to be able to do something:
Ok so when my character comes into position of the building he/she needs to enter a text element pops up saying ‘Press ‘G’ to enter’ now that i have that how would i be able to press ‘G’ and enter a new scene when that happens?
This was an example of my code:

this.getSceneUrl(/*sceneName*/)
if (buttonClicked) {
this.loadSceneHierachy();
this.destroyOldSceneHierarchy();
}