I’m creating a real-time tour simulation. And would like the first person controller to teleport to a new position on contact with certain "Gate"s.
However I found that the normally used transform.position=(x,x,x) doesn’t work.
I tried controller=GetComponent(CharacterController) and then use controller.Move(), this works fine but can only transport the character for a certain distance(i.e. only relative position), but wouldn’t go to the absolute position with respect to the world as I expect. Moreover, this Move() function is also affected by the character’s speed.
I also tried something like:
var Position_elevator:Vector3=new Vector3(-110,0,20);
function OnControllerColliderHit (hit:ControllerColliderHit){
var transform_position:Vector3;
if(hit.transform.name=="Cube_CorridortoElevator")
transform_position=Position_elevator;
transform.position=transform_position;
}
//or, //transform.position.Set(transform_position.x,transform_position.y,transform_position.z)
//which still doesn’t work…
Is there any good way to change the character’s position abruptly to a given position?
Thank you very much!