Skip to content

Commit 60001a6

Browse files
committed
Add camera shake and fade transition to main menu
Introduces a Cinemachine noise profile and camera shake effect during the spaceship launch sequence in the main menu. Adds a fade panel and transition animation to the UI for smoother scene changes. Refactors networking game start logic to support pre-game sequences. Updates material sun direction values and various UI/UX style improvements.
1 parent 7882063 commit 60001a6

File tree

20 files changed

+272
-75
lines changed

20 files changed

+272
-75
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: b7f59e54f2bfd184b9dd451a678d089b, type: 3}
13+
m_Name: CinemachineCamera_Main Noise Profile
14+
m_EditorClassIdentifier:
15+
PositionNoise:
16+
- X:
17+
Frequency: 0.5
18+
Amplitude: 0.5
19+
Constant: 0
20+
Y:
21+
Frequency: 0
22+
Amplitude: 0
23+
Constant: 0
24+
Z:
25+
Frequency: 0
26+
Amplitude: 0
27+
Constant: 0
28+
- X:
29+
Frequency: 15
30+
Amplitude: 0.03
31+
Constant: 0
32+
Y:
33+
Frequency: 0
34+
Amplitude: 0
35+
Constant: 0
36+
Z:
37+
Frequency: 0
38+
Amplitude: 0
39+
Constant: 0
40+
OrientationNoise: []

Red Strike/Assets/CameraSystem/CinemachineCamera_Main Noise Profile.asset.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Red Strike/Assets/MainMenuSystem/MainMenu.cs

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,24 @@ public class MainMenu : MonoBehaviour
2222
public CinemachineCamera cinemachineCamera_Options;
2323
public CinemachineCamera cinemachineCamera_Credits;
2424

25+
private CinemachineBasicMultiChannelPerlin cameraNoise_Main;
26+
2527
[Header("Spaceship Animation")]
2628
public GameObject spaceShip;
2729
public float shipDuration = 5f;
30+
public float shipMaxShake = 3f;
2831
public Vector3 shipStartPosition;
2932
public Vector3 targetPosition;
33+
public AnimationCurve shipCurve;
34+
private bool isShaking = false;
35+
private float shakeElapsed = 0f;
3036

3137
[Header("System References")]
3238
public Settings settings;
3339

3440
private void Start()
3541
{
42+
cameraNoise_Main = cinemachineCamera_Main.GetComponent<CinemachineBasicMultiChannelPerlin>();
3643
if (spaceShip != null)
3744
{
3845
spaceShip.transform.position = shipStartPosition;
@@ -64,10 +71,28 @@ private void Update()
6471

6572
if (planetTransform != null)
6673
planetTransform.Rotate(Vector3.up, planetRotationSpeed * Time.deltaTime);
74+
75+
if (isShaking)
76+
{
77+
shakeElapsed += Time.deltaTime;
78+
float shakeAmount = shipMaxShake * (1f - (shakeElapsed / shipDuration));
79+
if (cameraNoise_Main != null)
80+
{
81+
cameraNoise_Main.AmplitudeGain = shakeAmount;
82+
}
83+
84+
if (shakeElapsed >= shipDuration)
85+
{
86+
isShaking = false;
87+
if (cameraNoise_Main != null)
88+
{
89+
cameraNoise_Main.AmplitudeGain = 0f;
90+
}
91+
}
92+
}
6793
}
6894

6995
public enum CameraState { Login, Main, Options, Credits }
70-
7196
public void SwitchToCamera(CameraState state)
7297
{
7398
cinemachineCamera_Login.Priority = 0;
@@ -92,21 +117,23 @@ public void SwitchToCamera(CameraState state)
92117
}
93118
}
94119

95-
private IEnumerator LaunchSequence(System.Action onComplete)
120+
public IEnumerator LaunchSequence()
96121
{
122+
isShaking = true;
123+
shakeElapsed = 0f;
124+
97125
if (cinemachineCamera_Main != null && spaceShip != null)
98126
{
99127
cinemachineCamera_Main.Target.TrackingTarget = spaceShip.transform;
100128
}
101129

102-
Vector3 initialPosition = spaceShip.transform.position;
103130
float elapsed = 0f;
104131

105132
while (elapsed < shipDuration)
106133
{
107134
if (spaceShip != null)
108135
{
109-
spaceShip.transform.position = Vector3.Lerp(initialPosition, targetPosition, elapsed / shipDuration);
136+
spaceShip.transform.position = Vector3.Lerp(shipStartPosition, targetPosition, elapsed / shipDuration);
110137
}
111138
elapsed += Time.deltaTime;
112139
yield return null;
@@ -116,8 +143,6 @@ private IEnumerator LaunchSequence(System.Action onComplete)
116143
{
117144
spaceShip.transform.position = targetPosition;
118145
}
119-
120-
onComplete?.Invoke();
121146
}
122147

123148
public void ApplyAudioSettings(float masterVol, float musicVol)

Red Strike/Assets/NetworkingSystem/GameBootstrap.cs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Fusion.Sockets;
44
using System.Collections.Generic;
55
using System;
6+
using System.Threading.Tasks;
67

78
namespace NetworkingSystem
89
{
@@ -20,6 +21,8 @@ public class GameBootstrap : MonoBehaviour, INetworkRunnerCallbacks
2021

2122
private NetworkRunner _runner;
2223

24+
public Func<Task> OnGameStarting;
25+
2326
private void Awake()
2427
{
2528
if (Instance == null)
@@ -33,7 +36,27 @@ private void Awake()
3336
}
3437
}
3538

36-
public async void StartGame(GameMode mode, string sessionName)
39+
public async void StartHost(string sessionName)
40+
{
41+
await StartSequenceAndGame(GameMode.Host, sessionName);
42+
}
43+
44+
public async void StartClient(string sessionName)
45+
{
46+
await StartSequenceAndGame(GameMode.Client, sessionName);
47+
}
48+
49+
private async Task StartSequenceAndGame(GameMode mode, string sessionName)
50+
{
51+
if (OnGameStarting != null)
52+
{
53+
await OnGameStarting.Invoke();
54+
}
55+
56+
await StartGame(mode, sessionName);
57+
}
58+
59+
private async Task StartGame(GameMode mode, string sessionName)
3760
{
3861
if (_runner != null) Destroy(_runner.gameObject);
3962

@@ -57,10 +80,7 @@ await _runner.StartGame(new StartGameArgs()
5780

5881
public void OnPlayerJoined(NetworkRunner runner, PlayerRef player)
5982
{
60-
if (runner.IsServer)
61-
{
62-
runner.Spawn(playerDataPrefab, Vector3.zero, Quaternion.identity, player);
63-
}
83+
if (runner.IsServer) runner.Spawn(playerDataPrefab, Vector3.zero, Quaternion.identity, player);
6484
}
6585

6686
public void OnPlayerLeft(NetworkRunner runner, PlayerRef player) { }

Red Strike/Assets/PlanetAtmosphereSystem/AtmosphereMaterial.mat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Material:
4747
- _GunesYonu: {r: -0.91, g: 0.4, b: 3.24, a: 0}
4848
- _RenkUzak: {r: 0, g: 0.10166844, b: 2.152374, a: 1}
4949
- _RenkYakin: {r: 0, g: 5.670685, b: 8, a: 1}
50-
- _SunDirection: {r: 0.11393173, g: -0.7546686, b: -0.64613837, a: 0}
50+
- _SunDirection: {r: -0.091949426, g: -0.8255108, b: 0.5568458, a: 0}
5151
m_BuildTextureStacks: []
5252
m_AllowLocking: 1
5353
--- !u!114 &1522106816477559216

Red Strike/Assets/PlanetAtmosphereSystem/CloudMaterial.mat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Material:
4343
m_Colors:
4444
- _Color: {r: 0, g: 3.8274493, b: 5.992155, a: 1}
4545
- _GunesYonu: {r: -1, g: 0, b: 0, a: 0}
46-
- _SunDirection: {r: 0.11393173, g: -0.7546686, b: -0.64613837, a: 0}
46+
- _SunDirection: {r: -0.091949426, g: -0.8255108, b: 0.5568458, a: 0}
4747
m_BuildTextureStacks: []
4848
m_AllowLocking: 1
4949
--- !u!114 &8499732345945835446

Red Strike/Assets/PlanetAtmosphereSystem/FogMaterial.mat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ Material:
5454
- _QueueControl: 0
5555
- _QueueOffset: 0
5656
m_Colors:
57-
- _SunDirection: {r: 0.11393173, g: -0.7546686, b: -0.64613837, a: 0}
57+
- _SunDirection: {r: -0.091949426, g: -0.8255108, b: 0.5568458, a: 0}
5858
m_BuildTextureStacks: []
5959
m_AllowLocking: 1

Red Strike/Assets/Scenes/Menu.unity

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ GameObject:
371371
- component: {fileID: 656923635}
372372
- component: {fileID: 656923634}
373373
- component: {fileID: 656923636}
374+
- component: {fileID: 656923637}
374375
m_Layer: 0
375376
m_Name: CinemachineCamera_Main
376377
m_TagString: Untagged
@@ -465,6 +466,23 @@ MonoBehaviour:
465466
Time: 1
466467
Smoothing: 30
467468
IgnoreY: 0
469+
--- !u!114 &656923637
470+
MonoBehaviour:
471+
m_ObjectHideFlags: 0
472+
m_CorrespondingSourceObject: {fileID: 0}
473+
m_PrefabInstance: {fileID: 0}
474+
m_PrefabAsset: {fileID: 0}
475+
m_GameObject: {fileID: 656923633}
476+
m_Enabled: 1
477+
m_EditorHideFlags: 0
478+
m_Script: {fileID: 11500000, guid: 68bb026fafb42b14791938953eaace77, type: 3}
479+
m_Name:
480+
m_EditorClassIdentifier:
481+
NoiseProfile: {fileID: 11400000, guid: 6de90b0da335151449f2f71f61322685, type: 2}
482+
PivotOffset: {x: 0, y: 0, z: 0}
483+
AmplitudeGain: 1
484+
FrequencyGain: 1
485+
m_NoiseOffsets: {x: 421.75458, y: -900.8506, z: 117.34094}
468486
--- !u!1 &995665647
469487
GameObject:
470488
m_ObjectHideFlags: 0
@@ -799,8 +817,42 @@ MonoBehaviour:
799817
cinemachineCamera_Credits: {fileID: 312053529}
800818
spaceShip: {fileID: 2738940240077496202}
801819
shipDuration: 5
820+
shipMaxShake: 3
802821
shipStartPosition: {x: 2.24, y: -0.6, z: -19}
803822
targetPosition: {x: 2.24, y: -0.6, z: -9.72}
823+
shipCurve:
824+
serializedVersion: 2
825+
m_Curve:
826+
- serializedVersion: 3
827+
time: 0
828+
value: 0
829+
inSlope: 2
830+
outSlope: 2
831+
tangentMode: 0
832+
weightedMode: 0
833+
inWeight: 0
834+
outWeight: 0
835+
- serializedVersion: 3
836+
time: 0.50163484
837+
value: 0.39272237
838+
inSlope: 0.025015866
839+
outSlope: 0.025015866
840+
tangentMode: 0
841+
weightedMode: 0
842+
inWeight: 0.35976583
843+
outWeight: 0.33333334
844+
- serializedVersion: 3
845+
time: 1.0041504
846+
value: 0.0000076293945
847+
inSlope: -1.6002946
848+
outSlope: -1.6002946
849+
tangentMode: 0
850+
weightedMode: 0
851+
inWeight: 0.124341875
852+
outWeight: 0
853+
m_PreInfinity: 2
854+
m_PostInfinity: 2
855+
m_RotationOrder: 4
804856
settings: {fileID: 11400000, guid: e041f970da61a87429a66823e0614072, type: 2}
805857
--- !u!4 &1693417822
806858
Transform:

Red Strike/Assets/UISystem/GameHUD.uxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</ui:VisualElement>
4949

5050
<!-- 4. TAM EKRAN KAPLAMALAR (Grid dışı, en üstte) -->
51-
<ui:Instance template="OverlayPanels" name="OverlayInstance" />
51+
<ui:Instance template="OverlayPanels" name="OverlayInstance" picking-mode="Ignore" style="position: absolute; width: 100%; height: 100%; left: 0; top: 0;" />
5252
<ui:VisualElement name="fade-panel" class="fade-panel" style="display: none;" />
5353

5454
</ui:VisualElement>

0 commit comments

Comments
 (0)