I need help, I was watching a video on how to make a game similar to crossy road with java script, but there is one error that says (10,15): error CS1519: Unexpected symbol `Vector3' in class, struct, or interface member declaration. How can I fix this?
public class Bounce : MonoBehaviour {
float lerpTime;
float currentLerpTime;
float perc = 1
Vector3 startPos;
Vector3 endPos;
bool firstInput;
public bool justJump;
void Update ()
{
if (Input.GetButtonDown ("up") || Input.GetButtonDown ("down") || Input.GetButtonDown ("left") || Input.GetButtonDown ("right"))
{
if (perc == 1) {
{
lerpTime = 1;
currentLerpTime = 0;
firstInput = true;
justJump = true;
}
}
startPos = gameObject.tranform.position;
if(Input.GetButtonDown("right") &&gameObject.transform.position == endPos)
{
endPos = new Vector3(transform.position.x + 1, transform.position.y,transform.position.z);
}
if(Input.GetButtonDown("left") &&gameObject.transform.position == endPos)
{
endPos = new Vector3(transform.position.x - 1, transform.position.y,transform.position.z);
}
if(Input.GetButtonDown("up") &&gameObject.transform.position == endPos)
{
endPos = new Vector3(transform.position.x, transform.position.y,transform.position.z + 1);
}
if(Input.GetButtonDown("down") &&gameObject.transform.position == endPos)
{
endPos = new Vector3(transform.position.x, transform.position.y,transform.position.z - 1);
}
if(firstInput == true)
{
currentLerpTime += Time.deltaTime * 5.5F;
perc = currentLerpTime / lerpTime;
gameObject.transform.position = Vector3.Lerp(startPos,endPos,perc);
if(perc > 0.8)
{
perc = 1;
}
if(Mathf.Round(perc) == 1)
{
justJump = false;
}
}
}
}
}
↧