hello , I write a code with new function but when save it this errors show up :
BCE0044: expecting (, found 'Action_Pass_1'.
UCE0001: ';' expected. Insert a semicolon at the
BCE0043: Unexpected token: if.
UCE0001: ';' expected. Insert a semicolon at the
BCE0044: expecting :, found ';'.
my code is this :
if( Pass_1 ){
Action_Pass_1();
}
}
//========= Actions function ==============//
function Action_Pass_1(){
if(Stage == false){
transform.Translate(0,0,Speed*Time.deltaTime);
}
if(Mathf.Abs(transform.position.z-SecoundPosition.z)< 0.1){
Stage = true;
}
thanks
Well, the first error probably refers to the previous function that’s missing a curly bracket somewhere.
Also at the end of the Action_Pass_1 function you need to add one more curly bracket as you haven't closed the function yet (from what's visible in the code provided).
here is the modified code. i modified this with the commented code,
function Update () {
// up
if( direction == 1 )
{
x = 0;
y = 0;
z = force;
}
// down
if( direction == 2 )
{
x = 0;
y = 0;
z = -force;
}
// left
if( direction == 3 )
{
x = -force;
y = 0;
z = 0;
}
// right
if( direction == 4 )
{
x = force;
y = 0;
z = 0;
}
// u-l
if( direction == 5 )
{
x = -force;
y = 0;
z = force;
}
//u-r
if( direction == 6 )
{
x = -force;
y = 0;
z = -force;
}
//d-l
if( direction == 7 )
{
x = force;
y = 0;
z = force;
}
//d-r
if( direction == 8 )
{
x = force;
y = 0;
z = -force;
}
// if player allow to shoot determine direction of it.
if(can_shoot){
// right shoot
if(direction == 4)
{
FirstPosition = gameObject.transform.position;
SecoundPosition.z = FirstPosition.z + Distance;
Shoot_1();
direction = 0;
}
// left shoot
if(direction == 3){
FirstPosition = gameObject.transform.position;
SecoundPosition.z = FirstPosition.z + Distance;
Shoot_2();
direction = 0;
}
}
// if player allow to pass determine direction of it .
if(can_pass){
// right pass
if(direction == 4)
{
FirstPosition = gameObject.transform.position;
SecoundPosition.z = FirstPosition.z + Distance;
Pass_1();
direction = 0;
}
// left pass
if(direction == 3){
FirstPosition = gameObject.transform.position;
SecoundPosition.z = FirstPosition.z + Distance;
Pass_2();
direction = 0;
}
// up pass
if( direction == 1){
Pass_left();
direction = 0;
}
// down pass
if( direction == 2){
Pass_right();
direction = 0;
}
}
//**************************************************************************
// test
//***************************************************************************
if( Input.GetKeyDown(KeyCode.H)){
FirstPosition = gameObject.transform.position;
SecoundPosition.x = FirstPosition.x;
SecoundPosition.y = FirstPosition.y;
SecoundPosition.z = FirstPosition.z + Distance;
}
if(Input.GetKeyUp(KeyCode.H)){
if(Pass_1){
Pass_1 = false;
}
if(!Pass_1){
Pass_1 = true;
}
}
//************************************************************
//*************************************************************
if( Pass_1 ){
Action_Pass_1();
}
}
//========= Actions function ==============//
function Action_Pass_1(){
if(Stage == false){
transform.Translate(0,0,Speed*Time.deltaTime);
}
if(Mathf.Abs(transform.position.z-SecoundPosition.z)< 0.1){
Stage = true;
}
if(Stage == true){
transform.Translate(0,0,-Speed*Time.deltaTime);
if(Mathf.Abs(transform.position.z-FirstPosition.z)< 0.1){
Pass_1 = false;
Stage = false;
}
}
}