In the script below when facing left is true I want my GameObject (the one this script is attached to) to reset its y position and then move it to the right while keeping its new y position. So on play give object a random y position within two specified points and then while keeping that new y position move it to the right. But Vector 3 will not allow me to assign a transform.position to it and gives me the error below.
Script:
#pragma strict
var bounceControllerScript : Bounce_Controller_Script;
var objectsOriginalPos : Vector3;
public var smooth : float;
private var newPosition : Vector3;
var stopPositioningTrigger = false;
function Awake ()
{
gameObject.transform.position.x = -8;
objectsOriginalPos = transform.position;
}
function Update ()
{
PositionChanging();
}
function PositionChanging ()
{
if (Bounce_Controller_Script.facingLeft == true)
{
var newPosition : Vector3 = new Vector3(-2.68, objectsOriginalPos, 0);
transform.position = Vector3.Lerp(transform.position, newPosition, smooth * Time.deltaTime);
}
}
Error
BCE0024: The type ‘UnityEngine.Vector3’ does not have a visible constructor that matches the argument list ‘(float, UnityEngine.Vector3, int)’.