Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutliple portal pairs simultaneously #19

Open
andriypartyshev opened this issue Dec 17, 2022 · 2 comments
Open

Mutliple portal pairs simultaneously #19

andriypartyshev opened this issue Dec 17, 2022 · 2 comments

Comments

@andriypartyshev
Copy link

Hey!
I was wondering how would you go about making it possible for more than one visible pair of portals in the scene?
How would you render the view from the other pair of portals?
image

A setup sort of like this

@MinerMinerMods
Copy link

MinerMinerMods commented Jan 1, 2023

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

@MinerMinerMods
Copy link

MinerMinerMods commented Jan 1, 2023

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;
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants