Load level and Transform possition

I have this code and Box Collider attached to my 2 EmptyObjects which should re-position my character back to other side and load new or previous level depending if player triggers it on left or right side.

I had it working ok when I had two separate scripts for one on left to load new and one on right to load previous levels.

I just wanted to combine it into one universal Object but now I am having issues with missingMethodException.

I know that it tries to do something because this exception comes up when I trrigger it.

Any sugestions or corrections?
Thank you.

CODE:

var Level = 1;

function OnTriggerEnter(other : Collider)
{

  if (other.transform.position.Vector3 (-17, other.transform.position.y, other.transform.position.z))
  {
    Application.LoadLevel(Level);
    Level++;
    other.transform.position = Vector3 (16, other.transform.position.y, other.transform.position.z);
  }

  if (other.transform.position.Vector3 (17,other.transform.position.y, other.transform.position.z))
  {
    Application.LoadLevel(Level);
    Level--;
    other.transform.position = Vector3 (-16, other.transform.position.y, other.transform.position.z);
  }
  
 DontDestroyOnLoad (transform.gameObject);
}

At least one of your issues is with your if statements…

 .... position.Vector3 ( ...

Isn’t correct usage…

should be…

.... position == Vector3 ( ...

so

var Level = 1;

function OnTriggerEnter(other : Collider)
{

  if (other.transform.position == Vector3 (-17, other.transform.position.y, other.transform.position.z))
  {
    Application.LoadLevel(Level);
    Level++;
    other.transform.position = Vector3 (16, other.transform.position.y, other.transform.position.z);
  }


  if (other.transform.position == Vector3 (17,other.transform.position.y, other.transform.position.z))
  {
    Application.LoadLevel(Level);
    Level--;
    other.transform.position = Vector3 (-16, other.transform.position.y, other.transform.position.z);
  }

but really I think you intended to do something like

var Level = 1;

function OnTriggerEnter(other : Collider)
{

  if (other.transform.position.x <= -17)
  {
    Application.LoadLevel(Level);
    Level++;
    other.transform.position = Vector3 (16, other.transform.position.y, other.transform.position.z);
  }


  if (other.transform.position.x >= 17)
  {
    Application.LoadLevel(Level);
    Level--;
    other.transform.position = Vector3 (-16, other.transform.position.y, other.transform.position.z);
  }

 DontDestroyOnLoad (transform.gameObject);
}

 DontDestroyOnLoad (transform.gameObject);
}

Works like a charm.
I actually had that before as … position == Vector3 ( … but I somehow erased it and it still didn’t work for me.
You got it work perfect.

Thanks Rod Green

I don’t want to milk this too much and it may be different thread but if someone can point me at how can I prevent repositioning.

When returning to previous level have all other objects that I moved stay in same position as they were when I left and not reload.

My guess is DontDestroyOnLoad but is there any other way?