Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Clamp gameobject to linerenderer?

Discussion in 'Scripting' started by Nsingh13, Jan 7, 2021.

  1. Nsingh13

    Nsingh13

    Joined:
    Dec 17, 2014
    Posts:
    36
    I have a gameobject that I want to always stay on the path of a linerenderer. How can I acheive this?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    31,294
    Set its position to a point on the line renderer!

    Vector3.Lerp can give you positions between points.
     
  3. Nsingh13

    Nsingh13

    Joined:
    Dec 17, 2014
    Posts:
    36
    Thanks for your reply. What if I'm trying to add force to a gameobject rigidbody, but I want it to stay on the path. I can't seem to figure this out.