BasicMovingPlatform.cs (1533B)
1 using System; 2 using UnityEngine; 3 4 namespace Slimecing.Environment.Moving.MovingPlatformLogic 5 { 6 public class BasicMovingPlatform : MovingController 7 { 8 [SerializeField] private Vector3 translationAxis = Vector3.right; 9 [SerializeField] private float translationPeriod = 10; 10 [SerializeField] private float translationSpeed = 1; 11 [SerializeField] private Vector3 rotationAxis = Vector3.up; 12 [SerializeField] private float rotSpeed = 10; 13 [SerializeField] private Vector3 oscillationAxis = Vector3.zero; 14 [SerializeField] private float oscillationPeriod = 10; 15 [SerializeField] private float oscillationSpeed = 10; 16 17 private Vector3 _originalPosition; 18 private Quaternion _originalRotation; 19 20 private void Start() 21 { 22 _originalPosition = mover.moverRigidbody.position; 23 _originalRotation = mover.moverRigidbody.rotation; 24 } 25 26 public override void TickMover(out Vector3 targetPosition, out Quaternion targetRotation, float deltaTime) 27 { 28 targetPosition = _originalPosition + 29 translationAxis.normalized * (Mathf.Sin(Time.time * translationSpeed) * translationPeriod); 30 Quaternion targetRotForOsc = Quaternion.Euler(oscillationAxis.normalized * (Mathf.Sin(Time.time * oscillationSpeed) * oscillationPeriod)) * _originalRotation; 31 targetRotation = Quaternion.Euler(rotationAxis * (rotSpeed * Time.time)) * targetRotForOsc; 32 } 33 } 34 }