Advertisement
Caminhoneiro

Mathf Unity case

Jan 21st, 2017
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 19.08 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class MathF : MonoBehaviour
  5. {
  6.     public GameObject cube;
  7.     public GameObject cilinder;
  8.  
  9.     void Update()
  10.     {
  11.         if (Input.GetKey(KeyCode.Space))
  12.         {
  13.             SmoothStepUpdate();
  14.         }
  15.     }
  16.  
  17.     //Conversor de graus para radianos
  18.     public float deg = 30.0F;
  19.     void Degrees2Rad()
  20.     {
  21.         float rad = deg * Mathf.Deg2Rad;
  22.         Debug.Log(deg + "degrees are equal to " + rad + " radians.");
  23.         Vector3 radMove = new Vector3(rad, 0, 0);
  24.         transform.position += radMove * Time.deltaTime;
  25.     }
  26.  
  27.     //Retorna a menor valor que uma float pode ter diferente de zero
  28.     bool isEqual(float a, float b)
  29.     {
  30.         if (a >= b - Mathf.Epsilon && a <= b + Mathf.Epsilon)
  31.             return true;
  32.         else
  33.             return false;
  34.     }
  35.  
  36.     void Infinity()
  37.     {
  38.         Debug.DrawLine(Vector3.zero, Vector3.forward * 100);
  39.         if (Physics.Raycast(Vector3.zero, Vector3.forward, Mathf.Infinity))
  40.             print("There is something in front of the object!");
  41.         else
  42.             print("Vazio existencial");
  43.     }
  44.  
  45.     void NegativeInfinity()
  46.     {
  47.         Debug.Log(Mathf.NegativeInfinity);
  48.     }
  49.  
  50.     public float radius = 30;
  51.     void PI()
  52.     {
  53.         float perimeter = 2 * Mathf.PI * radius;
  54.         Debug.Log("The perimeter of the circle is: " + perimeter);
  55.         Vector3 radMove = new Vector3(0, 0, perimeter);
  56.         transform.position += radMove * Time.deltaTime;
  57.     }
  58.  
  59.     public float rad = 15;
  60.     void Rad2Degrees()
  61.     {
  62.         float deg = rad * Mathf.Rad2Deg;
  63.         Debug.Log(rad + " radians are equal to " + deg + " degrees.");
  64.         Vector3 radMove = new Vector3(0, 0, rad);
  65.         transform.position += radMove * Time.deltaTime;
  66.     }
  67.  
  68.     public float abs = -10.5f;
  69.     void AbsoluteValue()
  70.     {
  71.         Debug.Log(Mathf.Abs(abs));
  72.         float newAbs = Mathf.Abs(this.gameObject.transform.position.y);
  73.         print(newAbs);
  74.     }
  75.  
  76.     public float arcCos;
  77.     void ArcCosine()
  78.     {
  79.         print(Mathf.Acos(arcCos));
  80.         Vector3 coss = new Vector3(arcCos, arcCos, arcCos);
  81.         transform.position += coss * Time.deltaTime;
  82.     }
  83.  
  84.     //Retorna o Episulum de duas floats
  85.     void Approximately()
  86.     {
  87.         if (Mathf.Approximately(1.0F, 10.0F / 10.0F))
  88.             print("The values are approximately the same");
  89.  
  90.         if (Mathf.Approximately(cilinder.transform.position.x * 0, cube.transform.position.x))
  91.             print("?");
  92.     }
  93.  
  94.     //Retorna o seno do arco
  95.     public float sinArc;
  96.     void SinArc()
  97.     {
  98.         float test = cilinder.transform.position.y;
  99.         print(Mathf.Asin(test));
  100.     }
  101.  
  102.     //Tamgente do arco (Mesmo esquema)
  103.     void TanArc()
  104.     {
  105.         //Do tests
  106.         print(Mathf.Atan(0.5F));
  107.     }
  108.  
  109.  
  110.     //Returns the angle in radians whose Tan is y/x.
  111.     //Return value is the angle between the x-axis and a 2D vector starting at zero and terminating at(x, y).
  112.     //Note: This function takes account of the cases where x is zero and returns the correct angle rather than throwing a division by zero exception
  113.     //Seta a posição do cilindro (Alvo qualquer) position(3,3,33) e estuda mais isso aqui
  114.  
  115.     public Transform target;
  116.     void TangentBetween2Values()
  117.     {
  118.         Vector3 relative = transform.InverseTransformPoint(target.position);
  119.         float angle = Mathf.Atan2(relative.x, relative.z) * Mathf.Rad2Deg;
  120.         cube.transform.Rotate(0, angle, 0);
  121.     }
  122.  
  123.  
  124.     //retorna menor int igual ou menor que a float
  125.     public float c;
  126.     void CeilCalc()
  127.     {
  128.         // Prints 10
  129.         Debug.Log(Mathf.Ceil(10.0F));
  130.         // Prints 11
  131.         Debug.Log(Mathf.Ceil(10.2F));
  132.         // Prints 11
  133.         Debug.Log(Mathf.Ceil(10.7F));
  134.         // Prints -10
  135.         Debug.Log(Mathf.Ceil(-10.0F));
  136.         // Prints -10
  137.         Debug.Log(Mathf.Ceil(-10.2F));
  138.         // Prints -10
  139.         Debug.Log(Mathf.Ceil(-10.7F));
  140.     }
  141.  
  142.     float shit = 10;
  143.     void CeilToInt()
  144.     {
  145.         var what = (Mathf.CeilToInt(shit));
  146.         //Debug.Log(Mathf.CeilToInt(10.0F));
  147.         //Debug.Log(Mathf.CeilToInt(10.2F));
  148.         //Debug.Log(Mathf.CeilToInt(10.7F));
  149.         //Debug.Log(Mathf.CeilToInt(-10.0F));
  150.         //Debug.Log(Mathf.CeilToInt(-10.2F));
  151.         //Debug.Log(Mathf.CeilToInt(-10.7F));
  152.  
  153.         Debug.Log(what.GetType());
  154.     }
  155.  
  156.     //Clamp easy
  157.     void Clampeia()
  158.     {
  159.         cube.transform.position = new Vector3(Mathf.Clamp(Time.time, 1.0F, 3.0F), 0, 0);
  160.  
  161.         //Another lvl of clamp
  162.         // Clamps the value 10 to be between 1 and 3.
  163.         // prints 3 to the console
  164.         Debug.Log(Mathf.Clamp(10, 1, 3));
  165.  
  166.         //Clampada binaria
  167.         cilinder.transform.position = new Vector3(Mathf.Clamp01(Time.time), 0, 0);
  168.     }
  169.  
  170.  
  171.     //Closest powers of 2, perfect numbers :D
  172.     void PoderDo2()
  173.     {
  174.         Debug.Log(Mathf.ClosestPowerOfTwo(7));
  175.         Debug.Log(Mathf.ClosestPowerOfTwo(19));
  176.     }
  177.  
  178.     public int numberOfSides;
  179.     public float polygonRadius;
  180.     public Vector2 polygonCenter;
  181.  
  182.     //Coseno da parada (feel the power!!!)
  183.     void DrawBusiness()
  184.     {
  185.         DebugDrawPolygon(polygonCenter, polygonRadius, numberOfSides);
  186.     }
  187.  
  188.     //Estudar com calma:
  189.     // Draw a polygon in the XY plane with a specfied position, number of sides
  190.     // and radius.
  191.     void DebugDrawPolygon(Vector2 center, float radius, int numSides)
  192.     {
  193.         // The corner that is used to start the polygon (parallel to the X axis).
  194.         Vector2 startCorner = new Vector2(radius, 0) + polygonCenter;
  195.  
  196.         // The "previous" corner point, initialised to the starting corner.
  197.         Vector2 previousCorner = startCorner;
  198.  
  199.         // For each corner after the starting corner...
  200.         for (int i = 1; i < numSides; i++)
  201.         {
  202.             // Calculate the angle of the corner in radians.
  203.             float cornerAngle = 2f * Mathf.PI / (float)numSides * i;
  204.  
  205.             // Get the X and Y coordinates of the corner point.
  206.             Vector2 currentCorner = new Vector2(Mathf.Cos(cornerAngle) * radius, Mathf.Sin(cornerAngle) * radius) + polygonCenter;
  207.  
  208.             // Draw a side of the polygon by connecting the current corner to the previous one.
  209.             Debug.DrawLine(currentCorner, previousCorner);
  210.  
  211.             // Having used the current corner, it now becomes the previous corner.
  212.             previousCorner = currentCorner;
  213.         }
  214.  
  215.         // Draw the final side by connecting the last corner to the starting corner.
  216.         Debug.DrawLine(startCorner, previousCorner);
  217.     }
  218.  
  219.     //QUE CODE DELICIA
  220.     float amplitudeX = 10.0f;
  221.     float amplitudeY = 5.0f;
  222.     float omegaX = 1.0f;
  223.     float omegaY = 5.0f;
  224.     float index;
  225.     public void MoveByCosNSin()
  226.     {
  227.         index += Time.deltaTime;
  228.         float x = amplitudeX * Mathf.Cos(omegaX * index);
  229.         float y = Mathf.Abs(amplitudeY * Mathf.Sin(omegaY * index));
  230.         cube.transform.localPosition = new Vector3(x, y, 0);
  231.     }
  232.  
  233.     //Calcula a menor diferença entre dois angulos por degraus
  234.     // VAI AJUDAR NO DELTA PRA CARALHO
  235.     //estuda mais isso
  236.     void MinorDifByDegree()
  237.     {
  238.         Debug.Log(Mathf.DeltaAngle(1080, 90));
  239.     }
  240.  
  241.     // elevado à potência e
  242.     //Math.Pow computes x y for some x and y.
  243.     //Math.Exp computes e x for some x, where e is Euler's number.
  244.     //Exp é bem mais rapido que Pow
  245.     public float e = 6;
  246.     void ElevadoAPotencia()
  247.     {
  248.         print(Mathf.Exp(e));
  249.     }
  250.  
  251.     //Returns the largest integer smaller to or equal to f.
  252.     //wtf???
  253.     void Floor()
  254.     {
  255.         Debug.Log(Mathf.Floor(10.0F));
  256.         Debug.Log(Mathf.Floor(10.2F));
  257.         Debug.Log(Mathf.Floor(10.7F));
  258.         Debug.Log(Mathf.Floor(-10.0F));
  259.         Debug.Log(Mathf.Floor(-10.2F));
  260.         Debug.Log(Mathf.Floor(-10.7F));
  261.     }
  262.  
  263.     //wtf² mas vira int :D tipo uma classe lá em cima.
  264.     void FloorToInt()
  265.     {
  266.         Debug.Log(Mathf.FloorToInt(10.0F));
  267.         Debug.Log(Mathf.FloorToInt(10.2F));
  268.         Debug.Log(Mathf.FloorToInt(10.7F));
  269.         Debug.Log(Mathf.FloorToInt(-10.0F));
  270.         Debug.Log(Mathf.FloorToInt(-10.2F));
  271.         Debug.Log(Mathf.FloorToInt(-10.7F));
  272.     }
  273.  
  274.     //Calculates the linear parameter t that produces the interpolant value within the range[a, b].
  275.     //Estuda depopis
  276.     public float walkSpeed = 5.0F;
  277.     public float runSpeed = 10.0F;
  278.     public float speed = 8.0F;
  279.     void StartLinearParameter()
  280.     {
  281.         float parameter = Mathf.InverseLerp(walkSpeed, runSpeed, speed);
  282.     }
  283.  
  284.     //bool retorna positivo se for uma potencia de 2
  285.     void IsPowerOf2()
  286.     {
  287.         //Booleano pra caralho
  288.         Debug.Log(Mathf.IsPowerOfTwo(7));
  289.         Debug.Log(Mathf.IsPowerOfTwo(32));
  290.     }
  291.  
  292.     //Lerp Business tu conhece
  293.  
  294.     // animate the game object from -1 to +1 and back
  295.     public float minimum = -1.0F;
  296.     public float maximum = 1.0F;
  297.  
  298.     // starting value for the Lerp    
  299.     static float t = 0.0f;
  300.  
  301.     void LerpUpdate()
  302.     {
  303.         // animate the position of the game object...
  304.         cilinder.transform.position = new Vector3(Mathf.Lerp(minimum, maximum, t), 0, 0);
  305.  
  306.         // .. and increate the t interpolater
  307.         t += 0.5f * Time.deltaTime;
  308.  
  309.         // now check if the interpolator has reached 1.0
  310.         // and swap maximum and minimum so game object moves
  311.         // in the opposite direction.
  312.         if (t > 1.0f)
  313.         {
  314.             float temp = maximum;
  315.             maximum = minimum;
  316.             minimum = temp;
  317.             t = 0.0f;
  318.         }
  319.     }
  320.  
  321.     //Lerp de sempre mas 360 graus irmão
  322.     public float minAngle = 0.0F;
  323.     public float maxAngle = 90.0F;
  324.     void LerpAngleUpdate()
  325.     {
  326.         float angle = Mathf.LerpAngle(minAngle, maxAngle, Time.time);
  327.         cube.transform.eulerAngles = new Vector3(0, angle, 0);
  328.     }
  329.     //The parameter t is not clamped and a value based on a and b is supported.
  330.     //If t is less than zero, or greater than one, then LerpUnclamped will result in a return value outside the range a to b.
  331.     void Lerpada()
  332.     {
  333.         Debug.Log(Mathf.LerpUnclamped(1, 20, 2));
  334.     }
  335.  
  336.     //Debugadando (Retorna o logaritimo da parada)
  337.     void DebugaLogaritmo()
  338.     {
  339.         Debug.Log(Mathf.Log(6, 2));
  340.     }
  341.  
  342.     //Debugadando (Retorna o logaritimo da parada com base 10)
  343.     void DebugaLogaritmo10()
  344.     {
  345.         Debug.Log(Mathf.Log10(100));
  346.     }
  347.  
  348.     //Retorna o máximo entre dois valores
  349.     void Maxxx()
  350.     {
  351.         Debug.Log(Mathf.Max(1.2f, 2.4f));
  352.     }
  353.  
  354.     //Retorna o mínimo entre dois valores
  355.     void Minnn()
  356.     {
  357.         Debug.Log(Mathf.Min(666, 777));
  358.     }
  359.  
  360.     //This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  361.     //Negative values of maxDelta pushes the value away from target.
  362.     //ESTUDA MAIS DPS
  363.     public float currStrength;
  364.     public float maxStrength;
  365.     public float recoveryRate;
  366.     void MoveTowardsUpdate()
  367.     {
  368.         currStrength = Mathf.MoveTowards(currStrength, maxStrength, recoveryRate * Time.deltaTime);
  369.     }
  370.  
  371.  
  372.     //Mesma fita de cima só que com rotations (Estuda ssapórra
  373.     public float targetAngle = 270.0F;
  374.     public float speedAngle = 45.0F;
  375.     void MoveTowardsAngleUpdate()
  376.     {
  377.         float angle = Mathf.MoveTowardsAngle(transform.eulerAngles.y, targetAngle, speedAngle * Time.deltaTime);
  378.         transform.eulerAngles = new Vector3(0, angle, 0);
  379.     }
  380.  
  381.     //Next power of 2
  382.     void NextPower2()
  383.     {
  384.         Debug.Log(Mathf.NextPowerOfTwo(7));
  385.         Debug.Log(Mathf.NextPowerOfTwo(139));
  386.     }
  387.  
  388.     //Perlin Noise (Pesquise mais a respeito na documentação, não tenho interesse nisso no momento) https://docs.unity3d.com/ScriptReference/Mathf.PerlinNoise.html
  389.     //Mathf.PerlinNoise
  390.  
  391.     //Vai e volta bro :D
  392.     void PingaPong()
  393.     {
  394.         cube.transform.position = new Vector3(Mathf.PingPong(Time.time, 3), transform.position.y, transform.position.z);
  395.     }
  396.  
  397.     //Mesma coisa que o Mathf.Exp porém mais lerdo :S
  398.     void Powwww()
  399.     {
  400.         print(Mathf.Pow(6, 1.8F));
  401.     }
  402.  
  403.     //Da loop no valor e nunca vai ser menor que 0 ou maior que o limite :D
  404.     //Obs: very nice
  405.     void Repete()
  406.     {
  407.         cilinder.transform.position = new Vector3(Mathf.Repeat(Time.time, 3), transform.position.y, transform.position.z);
  408.     }
  409.  
  410.     //Não entendi porra nenhuma
  411.     //Obs: "If the number ends in .5 so it is halfway between two integers, one of which is even and the other odd, the even number is returned."
  412.     //Essa parada de número primo chamou atenção, olha melhor depois :D
  413.  
  414.     void Round()
  415.     {
  416.         // Prints 10
  417.         Debug.Log(Mathf.Round(10.0f));
  418.  
  419.         // Prints 10
  420.         Debug.Log(Mathf.Round(10.2f));
  421.  
  422.         // Prints 11
  423.         Debug.Log(Mathf.Round(10.7f));
  424.  
  425.         // Prints 10
  426.         Debug.Log(Mathf.Round(10.5f));
  427.  
  428.         // Prints 12
  429.         Debug.Log(Mathf.Round(11.5f));
  430.  
  431.         // Prints -10
  432.         Debug.Log(Mathf.Round(-10.0f));
  433.  
  434.         // Prints -10
  435.         Debug.Log(Mathf.Round(-10.2f));
  436.  
  437.         // Prints -11
  438.         Debug.Log(Mathf.Round(-10.7f));
  439.  
  440.         // Prints -10
  441.         Debug.Log(Mathf.Round(-10.5f));
  442.  
  443.         // Prints -12
  444.         Debug.Log(Mathf.Round(-11.5f));
  445.     }
  446.  
  447.     //Denovo essa merda, converte pra int a mesma fita de cima
  448.     //Obs: Apesar do trocadilho no nome do metodo não tem spin nenhum. (Até que prove ao contrário)
  449.     void SpinMeAround()
  450.     {
  451.         Debug.Log(Mathf.RoundToInt(10.0F));
  452.         Debug.Log(Mathf.RoundToInt(10.2F));
  453.         Debug.Log(Mathf.RoundToInt(10.7F));
  454.         Debug.Log(Mathf.RoundToInt(10.5F));
  455.         Debug.Log(Mathf.RoundToInt(11.5F));
  456.         Debug.Log(Mathf.RoundToInt(-10.0F));
  457.         Debug.Log(Mathf.RoundToInt(-10.2F));
  458.         Debug.Log(Mathf.RoundToInt(-10.7F));
  459.         Debug.Log(Mathf.RoundToInt(-10.5F));
  460.         Debug.Log(Mathf.RoundToInt(-11.5F));
  461.  
  462.         //Basciamente mesma logica aplicada no CeilCalc
  463.     }
  464.  
  465.     //Sign
  466.     void Sign()
  467.     {
  468.         Debug.Log(Mathf.Sign(-10));
  469.         Debug.Log(Mathf.Sign(10));
  470.     }
  471.    
  472.     //Estuda mais isso aqui deppis
  473.     public Transform alllvo;
  474.     public float smoothTime = 0.3F;
  475.     private float yVelocity = 0.0F;
  476.     void SmoothDampUpdate()
  477.     {
  478.         float newPosition = Mathf.SmoothDamp(transform.position.y, alllvo.position.y, ref yVelocity, smoothTime);
  479.         cube.transform.position = new Vector3(transform.position.x, newPosition, transform.position.z);
  480.     }
  481.  
  482.     //Mesmo de cima porém com rotation :D (Util pro delta talvez)
  483.     public Transform alllvo2;
  484.     public float smooth = 0.3F;
  485.     public float distance = 5.0F;
  486.     private float yVelocity2 = 0.0F;
  487.     void SmoothDampAngleUpdate()
  488.     {
  489.         float yAngle = Mathf.SmoothDampAngle(transform.eulerAngles.y, alllvo2.eulerAngles.y, ref yVelocity, smooth);
  490.         Vector3 position = alllvo2.position;
  491.         position += Quaternion.Euler(0, yVelocity2, 0) * new Vector3(0, 0, -distance);
  492.         cube.transform.position = position;
  493.         cube.transform.LookAt(alllvo2);
  494.     }
  495.  
  496.     //Basicamente um lerp porém a velocidade vai aumentando com o tempo
  497.     public float minimumSmoothStep = 10.0F;
  498.     public float maximumSmoothStep = 20.0F;
  499.     public float duration = 5.0F;
  500.     private float startTime;
  501.     void SmoothStepUpdate()
  502.     {
  503.         startTime = Time.time;
  504.         float t = (Time.time - startTime) / duration;
  505.         cube.transform.position = new Vector3(Mathf.SmoothStep(minimumSmoothStep, maximumSmoothStep, t), 0, 0);
  506.     }
  507.  
  508.     //Raiz quadrada pitagoras o de sempre
  509.     // The formula made famous by Pythagoras, also used internally by
  510.     // Vector3.Distance and several other standard functions.
  511.     float HypotenuseLength(float sideALength, float sideBLength)
  512.     {
  513.         return Mathf.Sqrt(sideALength * sideALength + sideBLength * sideBLength);
  514.     }
  515.  
  516.     //N vou explicar isso
  517.     void Tangente()
  518.     {
  519.         print(Mathf.Tan(0.5F));
  520.     }
  521.  
  522.     //***TRIGONOMETRIA***//
  523.  
  524.     //Oscillator por Seno:
  525.     Vector3 oscillatorStartPosition;
  526.    
  527.     void Oscillator()
  528.     {
  529.         oscillatorStartPosition = cube.transform.position;
  530.  
  531.         float x = oscillatorStartPosition.x;
  532.         float y = 20 * Mathf.Sin(Time.timeSinceLevelLoad) + oscillatorStartPosition.y;
  533.         float z = oscillatorStartPosition.z;
  534.  
  535.         cilinder.transform.position = new Vector3(x, y, z);
  536.     }
  537.  
  538.     //SENO E COSCENO (Again)
  539.     public bool useSin;
  540.     public bool useCos;
  541.  
  542.     void UpdateOscillator()
  543.     {
  544.         oscillatorStartPosition = cilinder.transform.position;
  545.  
  546.         float x = oscillatorStartPosition.x;
  547.         float y = oscillatorStartPosition.y;
  548.         float z = oscillatorStartPosition.z;
  549.  
  550.         if (useSin)
  551.             y = y + 20 * Mathf.Sin(Time.timeSinceLevelLoad);
  552.         if (useCos)
  553.             x = x + 20 * Mathf.Cos(Time.timeSinceLevelLoad);
  554.  
  555.         cilinder.transform.position = new Vector3(x, y, z);
  556.     }
  557.  
  558.     //Phase Shift
  559.     void UpdatePhaseShift()
  560.     {
  561.         oscillatorStartPosition = cilinder.transform.position;
  562.  
  563.         float x = oscillatorStartPosition.x;
  564.         float y = oscillatorStartPosition.y;
  565.         float z = oscillatorStartPosition.z;
  566.  
  567.         if (useSin)
  568.             y = y + 20 * Mathf.Sin(Time.timeSinceLevelLoad);
  569.         if (useCos)
  570.             x = x + 20 * Mathf.Sin(Time.timeSinceLevelLoad + Mathf.PI/2);
  571.  
  572.         cilinder.transform.position = new Vector3(x, y, z);
  573.     }
  574.  
  575.     //Tangente
  576.     void TanOscillator()
  577.     {
  578.         oscillatorStartPosition = cilinder.transform.position;
  579.  
  580.         float x = oscillatorStartPosition.x;
  581.         float y = oscillatorStartPosition.y;
  582.         float z = oscillatorStartPosition.z;
  583.  
  584.         z = z + 10 * Mathf.Tan(Time.timeSinceLevelLoad * 3);
  585.  
  586.         cilinder.transform.position = new Vector3(x, y, z);
  587.     }
  588.  
  589.     //Amplitude e frequência
  590.     //Recomendavel copiar só esse algoritmo e colocar em varios objetos :)
  591.     public float amplitude; //Copie e de um valor menor valor para cada um que passar (coloque um do lado do outro que vai ser da hora, irmão)
  592.     public float frequency;
  593.     public float phaseShift;
  594.  
  595.     void UpdateAmplitudeAndFrequency()
  596.     {
  597.         oscillatorStartPosition = cilinder.transform.position;
  598.  
  599.         float x = oscillatorStartPosition.x;
  600.         float y = oscillatorStartPosition.y;
  601.         float z = oscillatorStartPosition.z;
  602.  
  603.         if (useSin)
  604.             y = y + 20 * Mathf.Sin(Time.timeSinceLevelLoad*frequency+phaseShift);
  605.         if (useCos)
  606.             x = x + 20 * Mathf.Cos(Time.timeSinceLevelLoad * frequency + phaseShift);
  607.  
  608.         transform.position = new Vector3(x, y, z);
  609.     }
  610.  
  611.     //Usar nos animais fugindo (veja a viabilidade)
  612.     void RunBambis()
  613.     {
  614.         oscillatorStartPosition = cilinder.transform.position;
  615.  
  616.         float x = oscillatorStartPosition.x;
  617.         float y = oscillatorStartPosition.y;
  618.         float z = oscillatorStartPosition.z;
  619.  
  620.         z = z + 10 * Mathf.Sin(Time.timeSinceLevelLoad) / Mathf.Cos(Time.timeSinceLevelLoad);
  621.  
  622.         transform.position = new Vector3(x, y, z);
  623.     }
  624.  
  625. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement