Mutliple portal pairs simultaneously
andriypartyshev opened this issue · 2 comments
Well you could go in and specify portal channels by making a portal Array[2] dictionary PortDict
. Also if you want to use 2 cameras then you need to specify the exact active camera for checking. Anyways you check for any portal in view(This is in the code) and then get one of the item's channel ID and then find the partner by getting saving our target like this private Portal target = <the checked portal>;
and prep the partner like this private Portal partner;
and then check and validate that the channel has a length of 2 in its array by running 'if ((PortDict.item(target.channel).length())!=2){return 1;}' if we are still running we can check each item like this if (!(target.equals(PortDict.item(target.channel).item(i)))){partner = PortDict.item(target.channel).item(i);}
then we can tell the partner to initialize a camera as its child and move it to the relative position. Deinitalize any cameras of portals where the partner has not been on screen in 40 draws for efficiency
This method also allows you to change the portals in real time. However you need to add to portal.cs
the function
`public int ChangeChannel(int channel){
if (channel == this.channel){
return 2;/No need to change here, Exiting/
}
bool valid = false
bool fixInvalid = true
foreach (var i in PortalDict.item(this.channel))
{
if (target.equals(PortDict.item(target.channel).item(i))){
PortDict[i] = nulll;
valid = true
}
index++;
}
if valid == false{
if (fixInvaild){
foreach(var di in PortalDict.items)
foreach(var ii in PortalDict.item(di))
{
if (target.equals(PortDict.item(di).item(ii))){
PortDict[ii] = nulll;
channel = di
valid = true
}
ii++;
}
}else{
return 3; /Invalid data, incorrect channel/
}
}
/to add more/
return 0;
}`