I didn’t quite understand what Ben was doing. The first time I was doing the course I didn’t understand and now I again revisit the topic of Mathf.Sin(). Still didn’t get it, so thought why not implement my own way, so I came up with my own oscillation script which works just like Ben but it is understandable for me. I don’t know if this is the right way of doing it.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Oscillator : MonoBehaviour
{
[SerializeField] Vector3 startingPos;
[SerializeField] Vector3 movementVector;
private void Start()
{
startingPos = transform.position;
}private void Update() { float sinWave = Mathf.Sin(Time.time); Vector3 offset = movementVector * sinWave; transform.position = offset + startingPos; }
}