My level design. I only did one level focusing on learning how to do stuff with C#, Particles, lighting, searching how to do X etc. I had a lot of fun doing it.
“Gameplay”:
Credits:
Stylized Water: Alexander Ameye (UAS)
Sci-fi Crate: Szymon Łukaszuk (UAS)
Low Poly Penguin: Mysticreator (Sketchfab)
Futuristic sci-fi alarm: Sanlega (Freesound.com)
Bang: AndreasTisell (Freesound.com)
indoor gas fireplace: Mr6728 (Freesound.com)
engine_vibrations_of_ferry_1: Ivolipa (Freesound.com)
Abstract wind howl interior: mixkit.com
Penguin sound: mingosounds.com
Underwater Ambience: Pixabay
…
I changed the sinus movement code to be for general prupose. I found that the code of the lecture starts moving from the middle ( Sinus movement: 0 to 1 then back to -1). I changed that and other things. Now it has its own time to resume movement where it stopped etc.
using UnityEngine;
public class SinusMovement : MonoBehaviour
{
// GUI
[SerializeField] Vector3 NewStartPosition;
[SerializeField] Vector3 EndPosition;
[SerializeField] [Range(0,1)] float MovementFactor;
[SerializeField] float period = 1;
[SerializeField] float NumberOfCycles = 0;
// Calculations
float cycles;
float tau = Mathf.PI * 2;
float rawSinWave;
float FixedNumberOfCycles;
// We need our own time
float timer = 0;
// Between 0 and 1 the stage of the path we are currently in.
Vector3 Offset;
// Options
[SerializeField] bool StartInCurrentPosition = true;
[SerializeField] bool ActivateMovement = false;
[SerializeField] bool Oscilation = false;
// Start is called before the first frame update
void Start()
{
if (StartInCurrentPosition)
{
// Get Start position
NewStartPosition = transform.position;
}
FixedNumberOfCycles = NumberOfCycles + 0.75f;
}
// Update is called once per frame
void Update()
{
// Activate movement
if (ActivateMovement && !(period <= Mathf.Epsilon))
{
if (Oscilation)
{
// Current cycle of the sinus circle. (Fixed start position)
cycles = (timer / period) + 0.75f;
rawSinWave = Mathf.Sin(cycles * tau); // Sinus value between -1 and 1 (Drawed by the circle)
// Adapt to our movement factor 0 to 1;
MovementFactor = (rawSinWave + 1f) / 2f;
timer += Time.deltaTime;
}
else
{
if (cycles < FixedNumberOfCycles)
{
// Current cycle of the sinus circle. (Fixed start position)
cycles = (timer / period) + 0.75f;
rawSinWave = Mathf.Sin(cycles * tau); // Sinus value between -1 and 1 (Drawed by the circle)
// Adapt to our movement factor 0 to 1;
MovementFactor = (rawSinWave + 1f) / 2f;
timer += Time.deltaTime;
}
}
// Compute Current position
Offset = EndPosition * MovementFactor;
transform.position = NewStartPosition + Offset;
}
}
}
Demo:
Have a nice day!