Skip to content

Commit

Permalink
#1 #2 Trail renderer no longer renders the jump on reloop by unparent…
Browse files Browse the repository at this point in the history
…ing, still need code to warn TimelineManager
  • Loading branch information
Yisas committed Feb 10, 2017
1 parent 7056bfd commit ef0ced9
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 114 deletions.
140 changes: 140 additions & 0 deletions Assets/Prefabs/Shadow Trail Renderer.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1788705545930800}
m_IsPrefabParent: 1
--- !u!1 &1788705545930800
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4166125126334564}
- component: {fileID: 96711776689594582}
m_Layer: 0
m_Name: Shadow Trail Renderer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4166125126334564
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1788705545930800}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!96 &96711776689594582
TrailRenderer:
serializedVersion: 2
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1788705545930800}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
m_Materials:
- {fileID: 2100000, guid: 9070154db9d0b5d4c9f02c4b0da14cf8, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
m_Time: 5e+11
m_Parameters:
serializedVersion: 2
widthMultiplier: 1
widthCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
colorGradient:
key0:
serializedVersion: 2
rgba: 4294967295
key1:
serializedVersion: 2
rgba: 4294967295
key2:
serializedVersion: 2
rgba: 0
key3:
serializedVersion: 2
rgba: 0
key4:
serializedVersion: 2
rgba: 0
key5:
serializedVersion: 2
rgba: 0
key6:
serializedVersion: 2
rgba: 0
key7:
serializedVersion: 2
rgba: 0
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime4: 0
atime5: 0
atime6: 0
atime7: 0
m_Mode: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
numCornerVertices: 0
numCapVertices: 0
alignment: 0
textureMode: 0
m_MinVertexDistance: 0.1
m_Autodestruct: 0
8 changes: 8 additions & 0 deletions Assets/Prefabs/Shadow Trail Renderer.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 1 addition & 99 deletions Assets/Prefabs/Test Shadow Cube.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ GameObject:
- component: {fileID: 65735452598567560}
- component: {fileID: 23834119766803998}
- component: {fileID: 114935342693874920}
- component: {fileID: 96677447906534260}
m_Layer: 0
m_Name: Test Shadow Cube
m_TagString: Untagged
Expand Down Expand Up @@ -94,104 +93,6 @@ BoxCollider:
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!96 &96677447906534260
TrailRenderer:
serializedVersion: 2
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1614062590372156}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
m_Materials:
- {fileID: 2100000, guid: 9070154db9d0b5d4c9f02c4b0da14cf8, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
m_Time: 10000000
m_Parameters:
serializedVersion: 2
widthMultiplier: 1
widthCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
colorGradient:
key0:
serializedVersion: 2
rgba: 4294967295
key1:
serializedVersion: 2
rgba: 4294967295
key2:
serializedVersion: 2
rgba: 0
key3:
serializedVersion: 2
rgba: 0
key4:
serializedVersion: 2
rgba: 0
key5:
serializedVersion: 2
rgba: 0
key6:
serializedVersion: 2
rgba: 0
key7:
serializedVersion: 2
rgba: 0
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime4: 0
atime5: 0
atime6: 0
atime7: 0
m_Mode: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
numCornerVertices: 0
numCapVertices: 0
alignment: 0
textureMode: 0
m_MinVertexDistance: 0.1
m_Autodestruct: 0
--- !u!114 &114935342693874920
MonoBehaviour:
m_ObjectHideFlags: 1
Expand All @@ -203,3 +104,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7d56eb97859cec942933713e1ace2796, type: 3}
m_Name:
m_EditorClassIdentifier:
hasTrail: 1
5 changes: 4 additions & 1 deletion Assets/Scene/Test Scenes/Testing Custom Timereset.unity
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
shadowPrefab: {fileID: 1614062590372156, guid: fcf9134591e22d94aa1b0215e54cef7b,
type: 2}
trailRendererPrefab: {fileID: 1788705545930800, guid: 89d696b01c8236c46a0925a288b34308,
type: 2}
--- !u!4 &238929857
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -833,7 +835,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
recordedTransform: {fileID: 2053729386}
recordedTrail: {fileID: 0}
recordedTrail: {fileID: 96711776689594582, guid: 89d696b01c8236c46a0925a288b34308,
type: 2}
--- !u!4 &2053729386 stripped
Transform:
m_PrefabParentObject: {fileID: 400000, guid: 5e9e851c0e142814dac026a256ba2ac0, type: 2}
Expand Down
19 changes: 16 additions & 3 deletions Assets/Scripts/Time Mechanics/Looper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

public class Looper : MonoBehaviour
{
// State variables
public bool hasTrail;

// Private State variables
bool looping = false;
bool trailAttatched = true; // Once the looping happens once, the trail needs to be unparented from the looper object

// Numeric variables
float loopingTimer;
Expand All @@ -32,7 +35,7 @@ void Update()

private void FixedUpdate()
{
if(looping)
if (looping)
{
if (recordedPositions.Count > 0)
{
Expand All @@ -46,7 +49,7 @@ private void FixedUpdate()
}
}

public void StartLooping(Queue<Vector3> recordedPositions, Queue<Quaternion> recordedRotations, Queue<float> recordedTimes, TrailRenderer trailRenderer)
public void StartLooping(Queue<Vector3> recordedPositions, Queue<Quaternion> recordedRotations, Queue<float> recordedTimes)
{
this.recordedPositions = recordedPositions;
this.recordedTimes = recordedTimes;
Expand Down Expand Up @@ -85,6 +88,16 @@ private void Reloop()
recordedRotations = new Queue<Quaternion>(originalRecordedRotations);
recordedTimes = new Queue<float>(originalRecordedTimes);

if (hasTrail)
if (trailAttatched)
{
// Unparent trail and toggle flag
GameObject trail = transform.GetComponentInChildren<TrailRenderer>().gameObject;
trail.transform.parent = null;

trailAttatched = false;
}

loopingTimer = 0;
}
}
10 changes: 1 addition & 9 deletions Assets/Scripts/Time Mechanics/Recorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public class Recorder : MonoBehaviour {

// Public references
public Transform recordedTransform; // NOTE TO SELF: GET REFERENCE ON START
public TrailRenderer recordedTrail;

// Private references
private TimelineManager timelineManager;
Expand Down Expand Up @@ -60,15 +59,11 @@ private void StartRecording()
{
recordingTimer = 0;

recordedTrail.enabled = true;

recording = true;
}

private void StopRecording()
{
recordedTrail.enabled = false;

recording = false;
}

Expand All @@ -83,9 +78,6 @@ private void RecordFrame()

private void CreateShadow()
{

recordedTrail.time = 100; // FIX ME TO NOT HARDCODED
timelineManager.CreateShadow(recordedPositions, recordedRotations, recordedTimes, recordedTrail);
recordedTrail.time = 500000000000; // FIX ME TO NOT HARDCODED
timelineManager.CreateShadow(recordedPositions, recordedRotations, recordedTimes);
}
}
8 changes: 6 additions & 2 deletions Assets/Scripts/Time Mechanics/TimelineManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
public class TimelineManager : Singleton<TimelineManager> {

public GameObject shadowPrefab;
public GameObject trailRendererPrefab;

List<GameObject> loopingShadows;

Expand All @@ -18,13 +19,16 @@ void Update () {

}

public void CreateShadow(Queue<Vector3> recordedPositions, Queue<Quaternion> recordedRotations, Queue<float> recordedTimes, TrailRenderer trailRenderer)
public void CreateShadow(Queue<Vector3> recordedPositions, Queue<Quaternion> recordedRotations, Queue<float> recordedTimes)
{
// NOTE TO SELF: CAST CONCERNS?
GameObject shadow = (GameObject) Instantiate(shadowPrefab);

GameObject trail = (GameObject)Instantiate(trailRendererPrefab, shadow.transform);
trail.transform.localPosition = new Vector3(0, 0, 0);

loopingShadows.Add(shadow);

shadow.GetComponent<Looper>().StartLooping(recordedPositions, recordedRotations, recordedTimes, trailRenderer);
shadow.GetComponent<Looper>().StartLooping(recordedPositions, recordedRotations, recordedTimes);
}
}

0 comments on commit ef0ced9

Please sign in to comment.