Problems with Trigonometry and LERPing
Hello everyone!
I have recently gotten back to Unity after a long hiatus of sorts. To try some stuff out, I made a simple test program.
The program was supposed to move a box through the trajectory of a cosine function, going down and then going up in the same position 5 units later. The code works, and the function is fine. However, the LERP function I used to modify the x value of the function, for some reason, accelerated on the start and slowed down by the end. While it did look nice, I wanted a simple, linear movement with no variation to speed.
I tried a lot of different solutions online, but none of them worked!
Here is the code:
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class TestTrig : MonoBehaviour {
 
     public float multiplier;
 
     float TrigFunc(float axisX)
     {
         float axisY = Mathf.Cos(2f * Mathf.PI * axisX);
         return axisY;
     }
 
     
 
     // Use this for initialization
     void Start () {
     }
     
     // Update is called once per frame
     void Update () {
 
         float x = Mathf.Lerp(transform.position.x, 5f, Time.deltaTime * 2f);
         float y = TrigFunc(x);
         transform.position = new Vector3(x, y, 0);
         
     }
 }
Your answer
 
 
             Follow this Question
Related Questions
How to find the right position of Vector3 using trigonometry 0 Answers
Script is not getting a reference. 1 Answer
changing rpm when shifting 1 Answer
Why isn't my object lerping ? C# 2 Answers
Help with Vector2.Lerp 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                