Trying to recreate “Portals” mechanics… Everything works fine, but… when i’m throwing the rigidbody into the INportal with AddForce, after apearing in OUTportal, rigidbody is still moving in the same direction as it was thrown.
void OnTriggerEnter (Collider collision){
ObjectToTeleport = collision.gameObject;
if(this.name == "portalIn"){
PortalOut = (GameObject) GameObject.Find ("portalOut");
if(PortalOut==null){
return;
}
ObjectToTeleport.transform.rotation= PortalOut.transform.rotation;
ObjectToTeleport.transform.position = PortalOut.transform.position;
ObjectToTeleport.transform.Translate(Vector3.forward * 2);
}
if(this.name == "portalOut"){
PortalIn = (GameObject) GameObject.Find ("portalIn");
if(PortalIn==null){
return;
}
ObjectToTeleport.transform.rotation= PortalIn.transform.rotation;
ObjectToTeleport.transform.position = PortalIn.transform.position;
ObjectToTeleport.transform.Translate(Vector3.forward * 2);
}
}
As U see i’m changing object’s rotation to match OUTportal’s rotation, but it does not help…