I found out how to do it myself :D I reworked the whole thing.
Why does this script loop and glitch?
I am making a game where a knife goes from point A to B and loops that, but when the knife's speed increases (it increases when scored +1) it glitches to random location on the axis between A and B, when it should just keep moving from same position with higher speed. Ask me more if you need to know and thanks for trying to help me!
void Update ()
{
transform.position = Vector3.Lerp(pos1, pos2, (Mathf.Sin(speed * Time.time) + 1.0f) / 2.0f);
}
Answer by KittenSnipes · Jun 27, 2018 at 01:19 AM
@Aappo You can try this:
void Update ()
{
transform.position = Vector3.MoveTowards(pos1, pos2, (Mathf.Sin(speed * Time.time) + 1.0f) / 2.0f);
}
If you have any questions or it doesn’t perform how It is supposed to feel free to comment about it on my answer and I will help :D
Ah, didn't work but thanks for trying to help. This is a glitch that I can call a feature, because it make the game harder but I just hate making stuff that I don't know why it does so into a feature.
Follow this Question
Related Questions
Game object position is stuck when using mathf.sin,Object's position stuck when using Math.sin 0 Answers
lerp works on (-6.5/y/z) but not on (+6.5/y/z) 0 Answers
Having some issues with camera position 1 Answer
place gameobject with transform.position and a Vector 3 1 Answer
Why Can't I get 2D object to Move? 1 Answer