- Home /
Question by
MrSplosion · Jan 16, 2011 at 06:15 PM ·
positionvector3lerp
Not Sure How to Get Around this Problem
I'm trying to make 1 object go towards another using Lerp on the X axis. I'm not completely sure but I think the problem is Lerp is a Vector3 but I'm trying to access the X position of the target variable(can someone correct me if I'm wrong?), because if I take out the .x part of my script I get no errors. Here is my script what am I doing wrong?
var target : Transform;
function Update(){ transform.position = Vector3.Lerp(transform.position, target.position.x, Time.time * 0.001);
}
Comment
Best Answer
Answer by Jessy · Jan 16, 2011 at 06:56 PM
If you're just concerned about the X axis, don't bother with Y and Z.
transform.position.x = Mathf.Lerp(transform.position.x, target.position.x, Time.time * 0.001);