暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

HeroMover.cs 556B

1234567891011121314151617181920212223242526
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class HeroMover : MonoBehaviour
  5. {
  6. public float Amplitude = 1.0f;
  7. public float Frequency = 1.0f;
  8. private Vector3 origin;
  9. private float offset;
  10. // Use this for initialization
  11. void Start()
  12. {
  13. origin = transform.position;
  14. }
  15. // Update is called once per frame
  16. void Update()
  17. {
  18. offset = Mathf.Sin(Time.time * Frequency * 4.0f) * Amplitude;
  19. transform.position = origin + Vector3.right * offset;
  20. }
  21. }