Question by
rinomoen92 · Jan 30, 2020 at 11:17 PM ·
positiontransform.positionif-statementstranslate
How do i simpy get the x position of an object inside the script attached to it, so i can use it to trigger an if event/print the value?
public float swerve = 0.01f;
void Update()
{
transform.Translate(swerve, 0f, TrafficSpeed * Time.deltaTime);
if (transform.position.x >= 7f)
{
Debug.Log("Swerving");
swerve = -0.01f;
}
}
Im trying to make the object change direction when the x value is equal to or higher than 8
Comment