Commit 95011ed1 authored by Parsa Rahmaty's avatar Parsa Rahmaty

Some bug fixes, Added new option to movable.cs

parent 6aac8dec
......@@ -223,6 +223,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 135398379}
- component: {fileID: 135398380}
m_Layer: 0
m_Name: Cannon Holder
m_TagString: Player
......@@ -245,6 +246,42 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &135398380
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 135398378}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e3cf5829d03eb97459c57901b7efff3d, type: 3}
m_Name:
m_EditorClassIdentifier:
animationCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0.017981736
outSlope: 0.017981736
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0.0962145
- serializedVersion: 3
time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &188865415
GameObject:
m_ObjectHideFlags: 0
......@@ -796,6 +833,7 @@ Transform:
- {fileID: 705507995}
- {fileID: 1697180674}
- {fileID: 409250574}
- {fileID: 907792243}
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......@@ -1007,6 +1045,124 @@ MonoBehaviour:
levelEditor:
- e18o12e18
- o4e12o4e12o4e12
--- !u!1 &907792242
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 907792243}
- component: {fileID: 907792247}
- component: {fileID: 907792246}
- component: {fileID: 907792245}
- component: {fileID: 907792244}
m_Layer: 0
m_Name: Plane (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &907792243
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 907792242}
m_LocalRotation: {x: -0.116670705, y: 0, z: 0, w: 0.9931707}
m_LocalPosition: {x: 0, y: 50, z: 1000}
m_LocalScale: {x: 250, y: 150, z: 100}
m_Children: []
m_Father: {fileID: 669958479}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: -13.4, y: 0, z: 0}
--- !u!114 &907792244
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 907792242}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5fbb70b48805cd04083940578d45f997, type: 3}
m_Name:
m_EditorClassIdentifier:
DeformAxis: 1
Frequency: 200
Phaze: 0
PeakMultiplier: 0.2
AnimatePhaze: 1
AnimationSpeed: 1
OffsetA: 9
OffsetB: 2
isStatic: 0
UseEffector: 0
Effector: {fileID: 0}
--- !u!64 &907792245
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 907792242}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 4
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &907792246
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 907792242}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 1a7565060d8b88d4ea99db5e5bae182c, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &907792247
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 907792242}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &963194225
GameObject:
m_ObjectHideFlags: 0
......@@ -1058,7 +1214,7 @@ Camera:
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
field of view: 65
orthographic: 0
orthographic size: 5
m_Depth: -1
......@@ -2476,7 +2632,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: cff00b706ee811b448467fa040390d67, type: 3}
m_Name:
m_EditorClassIdentifier:
smoothing: 0.05
smoothing: 0.3
--- !u!4 &2140978675
Transform:
m_ObjectHideFlags: 0
......@@ -2515,7 +2671,6 @@ GameObject:
m_Component:
- component: {fileID: 2145345063}
- component: {fileID: 2145345062}
- component: {fileID: 2145345064}
m_Layer: 0
m_Name: Stack Holder
m_TagString: Untagged
......@@ -2552,19 +2707,6 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2145345064
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2145345061}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6f5b4fb209166f945960c270dd4516fa, type: 3}
m_Name:
m_EditorClassIdentifier:
smoothing: 1
--- !u!1001 &2984237214688264135
PrefabInstance:
m_ObjectHideFlags: 0
......
......@@ -9,6 +9,9 @@ public class Movable : MonoBehaviour
public Vector3 targetPosition { get; private set; }
private float time;
private float timeToReachTarget;
// AnimationCurve-based movement field
[SerializeField] private AnimationCurve animationCurve;
private float value;
//=====================================================
// Direction-based movement fields
......@@ -20,6 +23,7 @@ public class Movable : MonoBehaviour
enum Mode
{
Destination,
CurveMovement,
Direction,
Neutral
}
......@@ -42,6 +46,12 @@ public class Movable : MonoBehaviour
{
transform.Translate(Vector3.Normalize(direction) * speed * Time.deltaTime, (isOnWorldSpace ? Space.World : Space.Self));
}
else if(mode == Mode.CurveMovement)
{
time += Time.deltaTime / timeToReachTarget;
value = animationCurve.Evaluate(time);
transform.position = Vector3.Lerp(startPosition, targetPosition, value);
}
}
public void SetDestination(Vector3 destination, float time)
......@@ -53,6 +63,12 @@ public class Movable : MonoBehaviour
mode = Mode.Destination;
}
public void SetDestinationWithCurve(Vector3 destination, float time)
{
SetDestination(destination, time);
mode = Mode.CurveMovement;
}
public void SetDirection(Vector3 direction, float speed, bool isOnWorldSpace)
{
this.direction = direction;
......
......@@ -18,7 +18,7 @@ public class MoveWithPlayer : MonoBehaviour
targetPosition = initialPosition;
}
void FixedUpdate()
void LateUpdate()
{
targetPosition = GameObject.FindWithTag("Player").transform.position + distance;
transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref m_Velocity, smoothing);
......
......@@ -17,7 +17,7 @@ public class RotateWithPlayer : MonoBehaviour
targetRotation = initialRotation;
}
void FixedUpdate()
void LateUpdate()
{
targetRotation = GameObject.FindWithTag("Player").transform.rotation;
transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, smoothing);
......
......@@ -105,7 +105,7 @@ public class ObstacleCircle : MonoBehaviour
private void Update()
{
// Rotate the obstacles based on the animation curve in rotationTime of that level
time += Time.deltaTime / rotationTimes[currentLevelIndex()];
time += Time.deltaTime;
if (time > rotationTimes[currentLevelIndex()])
time = 0f;
transform.localEulerAngles += new Vector3(0f, rotationSpeedCurve[currentLevelIndex()].Evaluate(time / rotationTimes[currentLevelIndex()]) * rotationSpeedMultiplier * Time.deltaTime, 0f);
......
......@@ -44,6 +44,6 @@ public class StackNode : MonoBehaviour
private void Descend()
{
movable.SetDestination(movable.targetPosition - new Vector3(0f, nodeHeight + nodeHeightDistance, 0f), descendTime);
movable.SetDestination(new Vector3(transform.position.x, movable.targetPosition.y - (nodeHeight + nodeHeightDistance), transform.position.z), descendTime);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment