Home / Forums / Secret Neighbor: Reversing PlayerRole (Neighbor in Disguise) & Basement Keycards in Unity

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Tutorial

Secret Neighbor: Reversing PlayerRole (Neighbor in Disguise) & Basement Keycards in Unity

NeighborSpy
Unity & Secret Neighbor Modder
VIP
Rep: 290
Join Date: May 2023
Posts: 17
Thanks: 76
2y ago · Mar 24, 2024 2:15 PM
#1
In Secret Neighbor (Unity engine with Photon networking), one player among the kids is secretly the Neighbor in disguise.

1. Identifying the Neighbor in Disguise:
Every player controller contains a networked role flag and transform state:

CPP
// Conceptual C# / Unity Component Layout
public class PlayerController : MonoBehaviourPunCallbacks {
    public PlayerRole currentRole; // Kid, Neighbor, Clown, Bagger, Leader, etc.
    public bool isTransformed;     // True if currently in true Neighbor form
    public float stamina;          // Current stamina [0.0 - 100.0]
    public Inventory inventory;    // Equipped keys & items
}

public enum PlayerRole {
    Kid_Bagger = 0,
    Kid_Leader = 1,
    Kid_Brave  = 2,
    Kid_Inventor = 3,
    Kid_Detective = 4,
    Kid_Scout = 5,
    Neighbor_Normal = 6,
    Neighbor_Clown  = 7,
    Neighbor_Butcher = 8
}


Even when the Neighbor is disguised as a regular kid, their networked
CPP
currentRole
integer is on the client.

2. Reading Colored Keycards (Red, Blue, Yellow, Green, Purple):
Keys scattered around the house derive from
CPP
KeyItem
or
CPP
InteractableKey
:
CPP
public class KeyItem : InteractableObject {
    public KeyColor keyColor; // Red, Blue, Yellow, Green, Purple, Basement
    public bool isCollected;  // True if in a player's inventory
}


Filtering out
CODE
isCollected == true
gives you the exact world positions of all remaining keys required to unlock the basement door!
NeighborSpy · Secret Neighbor & Unity Netcode
PlayerRole, Keycards, Basement Locks & Stamina inspection
The following users thanked NeighborSpy for this post:
KeycardMaster
Item ESP & Unity UI Dev
MEMBER
Rep: 215
Join Date: Oct 2023
Posts: 19
Thanks: 54
2y ago · Mar 24, 2024 4:30 PM
#2
Great breakdown! When rendering Keycard ESP with ImGui, color-coding each key by its enum value makes finding them instant:

CPP
ImU32 GetKeyColor(KeyColor color) {
    switch (color) {
        case KeyColor::Red:    return IM_COL32(255, 60, 60, 255);
        case KeyColor::Blue:   return IM_COL32(60, 160, 255, 255);
        case KeyColor::Yellow: return IM_COL32(255, 220, 40, 255);
        case KeyColor::Green:  return IM_COL32(60, 255, 100, 255);
        case KeyColor::Purple: return IM_COL32(200, 80, 255, 255);
        default:               return IM_COL32(255, 255, 255, 255);
    }
}
KeycardMaster | Keycard & Objective ESP Specialist
RustMechanic
Unity & IL2CPP Reverser
VIP
Rep: 295
Join Date: Nov 2022
Posts: 32
Thanks: 74
2y ago · Mar 24, 2024 7:12 PM
#3
In Unity IL2CPP builds of Secret Neighbor, you can find all key instances using
CPP
Object.FindObjectsOfType<KeyItem>()
or caching them in a
CPP
std::vector
whenever
CODE
KeyItem.Start()
executes.
RustMechanic | IL2CPP & Unity Engine Analysis
ZeroMemory
Member
MEMBER
Rep: 75
Join Date: Oct 2024
Posts: 32
Thanks: 18
2y ago · Mar 25, 2024 9:45 AM
#4
Originally Posted by @NeighborSpy
Even when the Neighbor is disguised as a regular kid, their networked currentRole integer is >= 6

That is so interesting that the role enum is broadcast to all clients from the start of the match! Thanks for the explanation!
ZeroMemory · Always experimenting