PortalsFX_RandomMoves.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. using UnityEngine;
  2. using System.Collections;
  3. public class PortalsFX_RandomMoves : MonoBehaviour {
  4. public float TimeMultipler = 0.2f;
  5. public float RangeMultipler = 0.2f;
  6. Transform t;
  7. Vector3 StartPosition;
  8. Vector3 RndArg1;
  9. Vector3 RndArg2;
  10. Vector3 RndArg3;
  11. // Use this for initialization
  12. void Start () {
  13. t = GetComponent<Transform> ();
  14. StartPosition = t.position;
  15. RndArg1 = Random.insideUnitSphere * 2;
  16. RndArg2 = Random.insideUnitSphere * 2;
  17. RndArg3 = Random.insideUnitSphere * 2;
  18. }
  19. // Update is called once per frame
  20. void Update () {
  21. var x = Time.time * TimeMultipler;
  22. var xPos = Mathf.Sin (Mathf.Sin (x*RndArg1.x) + x * RndArg1.y) + Mathf.Cos (Mathf.Cos (x) * RndArg1.z + x);
  23. var yPos = Mathf.Sin (Mathf.Sin (x*RndArg2.x) + x * RndArg2.y) + Mathf.Cos (Mathf.Cos (x) * RndArg2.z + x);
  24. var zPos = Mathf.Sin (Mathf.Sin (x*RndArg3.x) + x * RndArg3.y) + Mathf.Cos (Mathf.Cos (x) * RndArg3.z + x);
  25. t.position = StartPosition + new Vector3(xPos, yPos, zPos) * RangeMultipler;
  26. //r.AddForce((StartPosition - new Vector3(xPos, yPos, zPos)) * RangeMultipler);
  27. }
  28. }