Skip to content

Commit

Permalink
Turn radius Fixed
Browse files Browse the repository at this point in the history
Jitter fix
  • Loading branch information
ParagBoro committed Feb 3, 2020
1 parent 4fb49e4 commit aa6016e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ crashlytics-build.properties
/GGJ2020/obj
/GGJ2020/Logs
/GGJ2020/Temp
/TapeIt/MonoBleedingEdge/EmbedRuntime
1 change: 0 additions & 1 deletion Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
<Compile Include="Assets\Scripts\Utilities\ProbabilityGroup.cs" />
<Compile Include="Assets\Scripts\Utilities\SimpleTimerArray.cs" />
<Compile Include="Assets\Scripts\Utilities\TypeUtilities.cs" />
<Compile Include="Assets\TestRigidBody.cs" />
<Reference Include="Unity.RenderPipeline.Universal.ShaderLibrary">
<HintPath>D:/Parag/GlobalGameJam2020/GGJ2020/Library/ScriptAssemblies/Unity.RenderPipeline.Universal.ShaderLibrary.dll</HintPath>
</Reference>
Expand Down
22 changes: 21 additions & 1 deletion Assets/Scenes/Environment.unity
Original file line number Diff line number Diff line change
Expand Up @@ -2410,6 +2410,11 @@ PrefabInstance:
propertyPath: m_Player
value:
objectReference: {fileID: 1425440733}
- target: {fileID: 2110099446476025165, guid: 28e64137460414c268ae931fb3c2471f,
type: 3}
propertyPath: m_AnchoredPosition.x
value: -22.300049
objectReference: {fileID: 0}
- target: {fileID: 4413687339875598747, guid: 28e64137460414c268ae931fb3c2471f,
type: 3}
propertyPath: m_LocalPosition.x
Expand Down Expand Up @@ -2465,11 +2470,26 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5388114570276696727, guid: 28e64137460414c268ae931fb3c2471f,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 19.699951
objectReference: {fileID: 0}
- target: {fileID: 6297312369232339573, guid: 28e64137460414c268ae931fb3c2471f,
type: 3}
propertyPath: m_Name
value: HUD
objectReference: {fileID: 0}
- target: {fileID: 6713140501537717192, guid: 28e64137460414c268ae931fb3c2471f,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -5.340027
objectReference: {fileID: 0}
- target: {fileID: 7905635006492613438, guid: 28e64137460414c268ae931fb3c2471f,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 19.699951
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 28e64137460414c268ae931fb3c2471f, type: 3}
--- !u!1001 &2141218753
Expand Down Expand Up @@ -2667,7 +2687,7 @@ PrefabInstance:
- target: {fileID: 7680917141668134391, guid: 14bd973fc598eaf40aa2c354c2ae7696,
type: 3}
propertyPath: m_RunTimeToDash
value: 0.3
value: 0.2
objectReference: {fileID: 0}
- target: {fileID: 7680917141668134391, guid: 14bd973fc598eaf40aa2c354c2ae7696,
type: 3}
Expand Down
29 changes: 28 additions & 1 deletion Assets/Scripts/Gameplay/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public enum PlayerStates
[SerializeField]
private float m_DefaultMoveSpeed = 10.0f;

[SerializeField]
private float m_PlayerTurnAngSpeed = 360.0f;

private bool m_bUseAnimEventDataForSpeed = false;

private Vector2 m_MoveDir = new Vector2(0.0f, 0.0f);
Expand Down Expand Up @@ -381,7 +384,7 @@ public void UpdateMoveState(State currState, float deltaTime)
if (turnDir.sqrMagnitude >= TURN_DIR_EPSILON)
{
turnDir.Normalize();
Vector3 forward = Vector3.Slerp(transform.forward, turnDir, 0.2f);
Vector3 forward = Rotate(transform.forward, turnDir, Mathf.Deg2Rad * m_PlayerTurnAngSpeed, deltaTime);//Vector3.Slerp(transform.forward, turnDir, 0.2f);
//transform.forward = forward.normalized;
transform.rotation = Quaternion.LookRotation(forward.normalized, Vector3.up);
}
Expand All @@ -394,6 +397,30 @@ public void EndMoveState(State endingState, State newState)
CurrentMoveSpeed = 0;
ClearCharacterFlag(CharacterFlag.eCF_ResetMoveSpeedAfterUse);
}

public Vector3 Rotate(Vector3 currDir, Vector3 targetDir, float angleSpeedRad, float deltaTime)
{
float radAngle = Mathf.Acos(Mathf.Clamp(Vector3.Dot(currDir, targetDir), 0.0f, 1.0f));
float angleToRotate = angleSpeedRad * deltaTime;

float targetAngle = Mathf.Clamp(radAngle - angleToRotate, 0.0f, Mathf.PI);

//Debug.Log("## Target angle : " + targetAngle);

Vector3 rotAxis = Vector3.Cross(targetDir, currDir);
const float EPSILON = 0.000001f;
if (rotAxis.sqrMagnitude <= EPSILON)
{
rotAxis = Vector3.up;
}
else
{
rotAxis.Normalize();
}

return Quaternion.AngleAxis(Mathf.Rad2Deg * targetAngle, rotAxis) * targetDir;
}

// End Walk, Run State
// -----------------

Expand Down
2 changes: 1 addition & 1 deletion ProjectSettings/QualitySettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ QualitySettings:
skinWeights: 4
textureQuality: 0
anisotropicTextures: 2
antiAliasing: 4
antiAliasing: 0
softParticles: 1
softVegetation: 1
realtimeReflectionProbes: 1
Expand Down

0 comments on commit aa6016e

Please sign in to comment.