Singularity/Library/PackageCache/com.unity.2d.pixel-perfect@.../Samples~/Scenes and Extras/Scenes/Scripts/HeroMover.cs

27 lines
556 B
C#
Raw Normal View History

2024-05-06 14:45:45 -04:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HeroMover : MonoBehaviour
{
public float Amplitude = 1.0f;
public float Frequency = 1.0f;
private Vector3 origin;
private float offset;
// Use this for initialization
void Start()
{
origin = transform.position;
}
// Update is called once per frame
void Update()
{
offset = Mathf.Sin(Time.time * Frequency * 4.0f) * Amplitude;
transform.position = origin + Vector3.right * offset;
}
}