I've been working on a new movement system for both third person and first person and I keep running into this problem where if the player (in this case a cylinder) rotates beyond 90 degrees it starts rotating fast like crazy.
I'm not sure if this is a bug but I need some help fixing.
Here in the video you can see in the top left, when the rotation goes beyond 90 it'll start glitching out:
Source code:
<GameMaker3D original="0" use2dHierarchy="1" guid="ED90DB4A-33AB-CE4A-A723-A157F6B1239C">
<Level name="thirdperson" isCollapse="0">
<SkyBox right="right.jpg" left="left.jpg" top="top.jpg" bottom="bottom.jpg" front="front.jpg" back="back.jpg" guid="D26F7083-456E-FF05-0FA0-A1588A382FA0" name="SkyBox1"/>
<Plane collision="1" static="1" guid="D591363E-31AE-330F-F58A-A158A6DDD6E7" castShadowsEnable="1" name="ground" xAxis="0" yAxis="0" zAxis="0" scaleX="10" scaleY="10" scaleZ="10"/>
<Cylinder collision="1" static="1" guid="1C387862-5BF3-D356-EB56-A159BA29BCA6" castShadowsEnable="1" x="0" y="-8" z="0" scaleX="0.4" scaleY="0.8" scaleZ="0.4" yAxis="60" name="player" isCollapse="0" visible="1">
<Loop isCollapse="1">
<IfKey key="W" isCollapse="1">
<Set var="localRotationY" value="camera.rotationY"/>
<Set var="input.text" value="W" isCollapse="1"/>
</IfKey>
<IfKey key="A" isCollapse="1">
<Set var="localRotationY" value="camera.rotationY-90" isCollapse="1"/>
<Set var="input.text" value="A" isCollapse="1"/>
</IfKey>
<IfKey key="D" isCollapse="1">
<Set var="localRotationY" value="camera.rotationY+90"/>
<Set var="input.text" value="D" isCollapse="1"/>
</IfKey>
<IfKey key="S" isCollapse="1">
<Set var="localRotationY" value="camera.rotationY-180"/>
<Set var="input.text" value="S"/>
</IfKey>
</Loop>
<Cube collision="1" static="1" castShadowsEnable="1" name="look_dir" height="15" x="0" y="83.65" z="141.02" width="25" depth="200"/>
</Cylinder>
<Cube collision="0" static="1" castShadowsEnable="1" name="cam_target" isCollapse="1" scaleY="0.2" scaleZ="0.2" scaleX="0.2" x="0.00" y="0.00" z="0.00" copyDir="Same Position">
<Loop isCollapse="1">
<Set var="x" value="player.x"/>
<Set var="y" value="player.y+50"/>
<Set var="z" value="player.z"/>
</Loop>
<Comment comment="what the camera will rotate towards"/>
</Cube>
<Cube collision="0" static="1" castShadowsEnable="1" name="cam_pos" isCollapse="1" scaleY="0.2" scaleZ="0.2" scaleX="0.2">
<Loop isCollapse="1">
<Comment comment="cam rot inputs"/>
<IfKey key="L" isCollapse="1">
<Increment var="cam_pos.rotationY" value="2"/>
</IfKey>
<IfKey key="J" isCollapse="1">
<Increment var="cam_pos.rotationY" value="-2"/>
</IfKey>
<IfKey key="I" isCollapse="1">
<Increment var="cam_pos.rotationX" value="2"/>
</IfKey>
<IfKey key="K" isCollapse="1">
<Increment var="cam_pos.rotationX" value="-2"/>
</IfKey>
<Comment comment="cameraXYZ = thisXYZ"/>
<Set var="camera.y" value="cam_pos.y"/>
<Set var="camera.x" value="cam_pos.x"/>
<Set var="camera.z" value="cam_pos.z"/>
<Comment comment="thisXYZ = playerXYZ"/>
<Set var="x" value="player.x"/>
<Set var="y" value="player.y"/>
<Set var="z" value="player.z"/>
<Set var="translateZ" value="-1000"/>
<Set var="cam_pos.rotationX"/>
</Loop>
</Cube>
<OnReady isCollapse="1">
<CameraController name="cam" mouseLock="1" forceFullScreen="1" controllerType="lookAt" lookAtObject="cam_target"/>
</OnReady>
<Label name="camrot_x_display" text="x" isCollapse="1" x="0"/>
<Label name="camrot_y_display" text="y" isCollapse="1" x="0.00" y="10.00" copyDir="Same Position"/>
<Label name="camrot_x_stats" x="10.00" isCollapse="1">
<Loop>
<Set var="camrot_x_stats.text" value="cam_pos.rotationX"/>
</Loop>
</Label>
<Label name="camrot_y_stats" x="10.00" isCollapse="1" y="10.00" copyDir="Same Position">
<Loop>
<Set value="cam_pos.rotationY" var="camrot_y_stats.text"/>
</Loop>
</Label>
<Message name="controls" text="IJKL to control camera
WASD to Move"/>
<Label name="input" y="25.00"/>
</Level>
</GameMaker3D>