Skip to content

Commit

Permalink
Merge pull request #3 from ototadana/improve-movement-operations
Browse files Browse the repository at this point in the history
Improve operability
  • Loading branch information
ototadana authored Nov 12, 2023
2 parents ed662a5 + e893b3e commit cea264e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 23 deletions.
4 changes: 0 additions & 4 deletions Assets/Scenes/TyDrone.unity
Original file line number Diff line number Diff line change
Expand Up @@ -17137,10 +17137,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2a34776537bb1074a961d3d90ec1b386, type: 3}
m_Name:
m_EditorClassIdentifier:
stickController: {fileID: 0}
enabledAutoRotation: 0
lastValue: 0
turntable: {fileID: 1079683939}
--- !u!1 &924872653
GameObject:
m_ObjectHideFlags: 0
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/CockpitStickController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ private void UpdateCommand()
rx = ToStickValue(tello.localPosition.x);
ry = ToStickValue(tello.localPosition.z);
ly = ToStickValue(tello.localPosition.y);
ly = ly < 0f ? ly * 1.5f : ly;
}
else
{
Expand Down
20 changes: 5 additions & 15 deletions Assets/Scripts/Turntable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,17 @@ private void Update()
return;
}

var currentY = Mathf.RoundToInt(transform.rotation.eulerAngles.y);
var currentY = Normalize(Mathf.RoundToInt(transform.rotation.eulerAngles.y));

if (target != int.MaxValue)
{
if (IsSame(target, currentY))
if (target == currentY)
{
target = int.MaxValue;
return;
}
transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(0f, target, 0f), 0.5f);
var speed = Mathf.Abs(target - currentY) > 30f ? 10f : 1f;
transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(0f, target, 0f), speed);
return;
}

Expand All @@ -86,7 +87,7 @@ private void Update()

if (yaw != currentY)
{
target = yaw;
target = Normalize(yaw);
}
}
}
Expand All @@ -101,17 +102,6 @@ public void UpdateOffset(float y)
offset = Mathf.RoundToInt(y);
}

private bool IsSame(int a, int b)
{
if (a == b)
{
return true;
}

return Normalize(a) == Normalize(b);

}

private int Normalize(int a)
{
a = a % 360;
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/VideoContainerDisplayPositions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private void Start()

public void Center()
{
UpdateScale(4f);
UpdateScale(5f);
Move(0f, 0f);
}

Expand Down
3 changes: 0 additions & 3 deletions ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,6 @@ PlayerSettings:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 11400000, guid: ab1b67dce0e107d458b7b6b5891213f5, type: 2}
- {fileID: 8820259372407401362, guid: 2250a865e36e4924bb482924a874ccb3, type: 2}
- {fileID: 7794255540170302434, guid: a0d9e1d8f1252fb44ac718c00197f71e, type: 2}
- {fileID: 11400000, guid: 1898d77cb101c3d4e828c778684076a5, type: 2}
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down

0 comments on commit cea264e

Please sign in to comment.