Search Unity

Question Clamp gameobject to linerenderer?

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

  1. Nsingh13

    Nsingh13

    Joined:
    Dec 17, 2014
    Posts:
    38
    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:
    38,742
    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:
    38
    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.