|
dear all.. i have a question, i want change my first person controller change the position when onTriggerEnter(); but not 0. can i use loadlevel? this is the code :
(comments are locked)
|
|
Try this var newPositionOnTriggerEnter = somewhere; if(other.tag == "Player"){ if(data.tE>=20){ transform.position = newPositionOnTriggerEnter; //Application.LoadLevel(0); --> this one print("done"); } else{ data.tE=data.tE+1; print(data.tE); exGUI.error=data.tE.ToString(); }}} ya, but which somewhere?
Aug 03 '12 at 08:29 PM
fadilRaditya
(comments are locked)
|

so u want to change the position of ur char onTrrigerEnter? or u want to load another scene?
for example the my player enter cube that hv function ontriggerenter() when come there i want my player go to other place/not other scent
add this script to the other object u r touching not your character
function OnTriggerEnter(other : Collider){
gameObject.Find("myPlayer").transform.position = vector3(1,2,3);
}
this would take ur playaer to this position. vector3(1,2,3);
u can place any other gameoobject and take its position and go there too just do something like
gameObject.Find("myPlayer").transform.position=gameObject.Find("otherPlace").transform.position;
sorry to late confirmation. there is error there vector3 unknown identifier
and when i change v to V it works, but when i hit the cube that have this script there is an error NullReferenceException testChangePosisition.OnTriggerEnter (UnityEngine.Collider other) (at Assets/script/testChangePosisition.js:5)