Skip to content

Commit

Permalink
Place the script to parent
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickk888SAMP committed Oct 9, 2022
1 parent 6a5c7ab commit 0c61041
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 157 deletions.
107 changes: 37 additions & 70 deletions Prefabs/RTSCameraController.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_Sprite: {fileID: 21300000, guid: b4de11f2a83575649945482b79dc9d3e, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
Expand Down Expand Up @@ -269,7 +269,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 54367b6c14cd2cd44b26e247fbafa018, type: 3}
m_Sprite: {fileID: 21300000, guid: 249069c2274f6f8458a54dce3c46a836, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
Expand Down Expand Up @@ -345,7 +345,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: ddccc331c8faa554ea73f2ef5eeb5539, type: 3}
m_Sprite: {fileID: 21300000, guid: 8e043ea7461509f4080942a00efcccd4, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
Expand Down Expand Up @@ -530,7 +530,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 4c57e9aab1362fe4d993dfbdd18ae409, type: 3}
m_Sprite: {fileID: 21300000, guid: ab2be9889b7675f4ab4f1323ff3dc6a6, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
Expand Down Expand Up @@ -606,7 +606,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 2956780e17625c7419c3098f3c9e17ea, type: 3}
m_Sprite: {fileID: 21300000, guid: b4de11f2a83575649945482b79dc9d3e, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
Expand Down Expand Up @@ -682,7 +682,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 202913089f033f64a89f43b23453124f, type: 3}
m_Sprite: {fileID: 21300000, guid: 961791aea211b6f42a09b0deb1e8a342, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
Expand Down Expand Up @@ -805,7 +805,6 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 5524602137987408595}
- component: {fileID: 5524602137987408594}
m_Layer: 0
m_Name: CameraTarget
m_TagString: Untagged
Expand All @@ -828,32 +827,6 @@ Transform:
m_Father: {fileID: 5524602138380265803}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &5524602137987408594
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5524602137987408593}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d57dde2bf9c4d00499473219ddadc409, type: 3}
m_Name:
m_EditorClassIdentifier:
virtualCamera: {fileID: 5524602137410515193}
cameraTilt: 50
cameraMouseSpeed: 2
cameraKeysSpeed: 4
cameraZoomSpeed: 4
cameraMoveDeadZone: 5
cameraZoomSmoothTime: 0.075
cameraZoomSlider: {fileID: 5524602137142699062}
cameraZoomMinMax: {x: 8, y: 100}
mouseDragCanvasGameObject: {fileID: 5524602137590102574}
mouseDragStartPoint: {fileID: 5524602137227135747}
mouseDragEndPoint: {fileID: 5524602137349566288}
rotateCameraCanvasGameObject: {fileID: 5524602137610333466}
compasUImageGameObject: {fileID: 5524602138760156461}
--- !u!1 &5524602138043651667
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -971,7 +944,6 @@ GameObject:
- component: {fileID: 5524602138118368226}
- component: {fileID: 5524602138118368225}
- component: {fileID: 5524602138118368224}
- component: {fileID: 5524602138118368227}
- component: {fileID: 5524602138118368228}
m_Layer: 0
m_Name: Main Camera
Expand Down Expand Up @@ -1046,39 +1018,6 @@ AudioListener:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5524602138118368239}
m_Enabled: 1
--- !u!114 &5524602138118368227
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5524602138118368239}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_RenderShadows: 1
m_RequiresDepthTextureOption: 2
m_RequiresOpaqueTextureOption: 2
m_CameraType: 0
m_Cameras: []
m_RendererIndex: -1
m_VolumeLayerMask:
serializedVersion: 2
m_Bits: 1
m_VolumeTrigger: {fileID: 0}
m_VolumeFrameworkUpdateModeOption: 2
m_RenderPostProcessing: 1
m_Antialiasing: 0
m_AntialiasingQuality: 2
m_StopNaN: 0
m_Dithering: 0
m_ClearDepth: 1
m_AllowXRRendering: 1
m_RequiresDepthTexture: 0
m_RequiresColorTexture: 0
m_Version: 2
--- !u!114 &5524602138118368228
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1122,6 +1061,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 5524602138380265803}
- component: {fileID: 1835259192517180277}
m_Layer: 0
m_Name: RTSCameraController
m_TagString: Untagged
Expand All @@ -1148,6 +1088,33 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1835259192517180277
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5524602138380265802}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d57dde2bf9c4d00499473219ddadc409, type: 3}
m_Name:
m_EditorClassIdentifier:
virtualCamera: {fileID: 5524602137410515193}
cameraTarget: {fileID: 5524602137987408595}
cameraTilt: 50
cameraMouseSpeed: 2
cameraKeysSpeed: 4
cameraZoomSpeed: 4
cameraMoveDeadZone: 5
cameraZoomSmoothTime: 0.075
cameraZoomSlider: {fileID: 5524602137142699062}
cameraZoomMinMax: {x: 8, y: 100}
mouseDragCanvasGameObject: {fileID: 5524602137590102574}
mouseDragStartPoint: {fileID: 5524602137227135747}
mouseDragEndPoint: {fileID: 5524602137349566288}
rotateCameraCanvasGameObject: {fileID: 5524602137610333466}
compasUImageGameObject: {fileID: 5524602138760156461}
--- !u!1 &5524602138529658979
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1214,7 +1181,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 60e5b6f4275daf245a26f5f15a7626dd, type: 3}
m_Sprite: {fileID: 21300000, guid: cf014d75d80a3e549a3f50378f524643, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
Expand Down Expand Up @@ -1329,7 +1296,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: e7f87ed8f4bf8574aa5ca9c26e77bccd, type: 3}
m_Sprite: {fileID: 21300000, guid: 4e461da48a71ced40b22069a944a2622, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
Expand Down
87 changes: 1 addition & 86 deletions Scenes/ExampleScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -2553,30 +2553,6 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 5524602137135840771, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Type
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5524602137135840771, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: b4de11f2a83575649945482b79dc9d3e, type: 3}
- target: {fileID: 5524602137135840771, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Color.a
value: 0.36862746
objectReference: {fileID: 0}
- target: {fileID: 5524602137227135749, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: 249069c2274f6f8458a54dce3c46a836, type: 3}
- target: {fileID: 5524602137349566290, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: 8e043ea7461509f4080942a00efcccd4, type: 3}
- target: {fileID: 5524602137610333468, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: ab2be9889b7675f4ab4f1323ff3dc6a6, type: 3}
- target: {fileID: 5524602137660462666, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_AnchorMax.x
value: 0
Expand All @@ -2589,50 +2565,6 @@ PrefabInstance:
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5524602137660462666, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_SizeDelta.y
value: 40
objectReference: {fileID: 0}
- target: {fileID: 5524602137660462667, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: b4de11f2a83575649945482b79dc9d3e, type: 3}
- target: {fileID: 5524602137660462667, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Color.a
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5524602137660462667, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Color.b
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5524602137660462667, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Color.g
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5524602137660462667, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Color.r
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5524602137700860035, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: 961791aea211b6f42a09b0deb1e8a342, type: 3}
- target: {fileID: 5524602137700860035, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Color.a
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5524602137987408594, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: cameraTilt
value: 60
objectReference: {fileID: 0}
- target: {fileID: 5524602137987408594, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: cameraZoomSpeed
value: 6
objectReference: {fileID: 0}
- target: {fileID: 5524602137987408594, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: cameraMouseSpeed
value: 4
objectReference: {fileID: 0}
- target: {fileID: 5524602138380265802, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Name
value: RTSCameraController
Expand Down Expand Up @@ -2681,24 +2613,7 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5524602138529658981, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: cf014d75d80a3e549a3f50378f524643, type: 3}
- target: {fileID: 5524602138529658981, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Color.a
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5524602138760156463, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: 4e461da48a71ced40b22069a944a2622, type: 3}
- target: {fileID: 5524602138760156463, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
propertyPath: m_Color.a
value: 1
objectReference: {fileID: 0}
m_RemovedComponents:
- {fileID: 5524602138118368227, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 48b147c9aa2a8394082c7e10a44f6b94, type: 3}
--- !u!1 &615080560
GameObject:
Expand Down
5 changes: 4 additions & 1 deletion Scripts/RTSCameraTargetController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public class RTSCameraTargetController : MonoBehaviour
[SerializeField]
private CinemachineVirtualCamera virtualCamera;

[SerializeField]
private Transform cameraTarget;

[Space]
[Header("Camera")]
[SerializeField]
Expand Down Expand Up @@ -212,6 +215,6 @@ private void MoveTargetRelativeToCamera(Vector3 direction, float speed)
camRight.Normalize();
Vector3 relativeDir = (camForward * direction.z) + (camRight * direction.x);

transform.Translate(relativeDir * (relativeZoomCameraMoveSpeed * speed) * Time.deltaTime);
cameraTarget.Translate(relativeDir * (relativeZoomCameraMoveSpeed * speed) * Time.deltaTime);
}
}

0 comments on commit 0c61041

Please sign in to comment.