Idk if you know hooking, but I can give ideas on what to hook & modify.
what method or what is responsible for disabling collision
You can disable gameobjects' colliders by hooking:
Code:
bool UnityEngine.Collider.get_enabled()
But hooking and changing this directly would mean that all colliders would get disabled. Meaning that not only would you go through walls, but also through the ground.
My idea:
1. Hook a Start() function or something similar that runs once. And also make an Array variable like: monoArray<void**>* GameObjectArray
2. Filter gameobjects: with either by tag
Code:
static GameObject[] UnityEngine.GameObject.FindGameObjectsWithTag(string tag)
(if walls etc. have a specific tag, you need to check game files)
or get all gameobjects for now, e.g.
Code:
static Object[] UnityEngine.Object.FindObjectsOfType(Type type)
type for the parameter:
Code:
static Type System.Type.GetType(string typeName)
So it would be FindObjectsOfType(GetType(CreateMonoString ("GameObject")).
In the start hook assign the array variable:
Code:
GameObjectArray = FindGameObjectsWithTag(CreateMonoString("wall" (etc.))
3. Hook an update function
4. Once you have the array of gameobjects, (I think) you can access the collider component with:
Code:
Component UnityEngine.GameObject.GetComponent(Type type)
So you could make a loop in the update hook like:
Code:
for (int i = 0; i < GameObjectArray->length; i++)
{
void* GO = GameObjectArray->getPointer()[i];
void* component = GetComponent(GO, GetType(CreateMonoString("Collider")
}
and change the enabled state with a trigger and the setter:
Code:
for (int i = 0; i < GameObjectArray->length; i++)
{
void* GO = GameObjectArray->getPointer()[i];
void* ColliderComp = GetComponent(GO, GetType(CreateMonoString("Collider");
//void UnityEngine.Collider.set_enabled(bool value)
set_Enabled(ColliderComp, !colliderOff);
}
if you use the FindObjectsOfType, you still need to filter the gameobjects. E.g. with int UnityEngine.GameObject.get_layer() or comparing UnityEngine.Object.get_name():
Code:
for (int i = 0; i < GameObjectArray->length; i++)
{
void* GO = GameObjectArray->getPointer()[i];
if (get_layer(GO) == x //or name logic)
{
void* ColliderComp = GetComponent(GO, GetType(CreateMonoString("Collider");
//void UnityEngine.Collider.set_enabled(bool value)
set_Enabled(ColliderComp, !colliderOff);
}
}
Hope you can get something out this mess
Credit to Numark for his FindObjectsByType tutorial
Finding & Creating instance of any classes and Static fields, methods.