if (!ORK.Control.CameraBlocked)
{
print("Block Camera");
ORK.Control.SetBlockCamera(1, true);
}
if (!ORK.Control.Blocked)
{
print("Block Controls");
ORK.Control.SetBlockControl(1, true);
}
if (ORK.Control.CameraBlocked)
{
print("Unblock Camera");
ORK.Control.SetBlockCamera(-1, true);
}
if (ORK.Control.Blocked)
{
print("Unblock Controls");
ORK.Control.SetBlockControl(-1, true);
}
It looks like you're new here. If you want to get involved, click one of these buttons!
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
In that case, also use the From Root option (and On Child Object), since ORK gets the camera via the Camera component.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Is the camera control actually blocked by ORK at some point in the game, e.g. by a game event or battle?
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
EDIT - i tried that, and it still didnt work.
EDIT2 - Could it be possible that ORK is using some other camera? There are other cameras in the scene which also have "MainCamera" tags but they are disabled. How can i check which camera ORK is using?
Hm, can you send me a small Unity test project with your setup?
E.g. zip it up and upload it on dropbox or something like that and send me the link to contact@orkframework.com - you can drastically reduce the size of the project by deleting the Library folder in the Unity project's folder.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I havent actually tested the issue in a separate project. i will test it in a blank project.
ORK'll use the main camera that's returned by Camera.main, or the first camera it finds if no main camera is tagged. If multiple main cameras are in the scene I'm not sure which one Unity will use, but probably not the one you use here (which I assume is spawned in later).
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
is there a code with which i can check which camera object is being searched for the Behviour when i call ORK.Control.SetBlockCamera(1, true);
You could also add the camera control component to ORK via scripting by adding this line in the component's Awake or Start function:
ORK.Control.AddCameraControl(this);
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
ORK.Game.Camera.name = "Test";
I tested and it changed the correct camera object name.
ORK.Control.AddCameraControl(this);
using code to set behavior works
Project just has a camera, light and game starter.
Camera is a single object with no parent or child. I have attached a BoxCollider to it and that is what i try to disable in the custom control.
public class BlockCameraBehaviour : MonoBehaviour
{
int counter;
private void Start()
{
counter = 0;
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
ORK.Game.Camera.name = "Button Pressed " + ++counter;
if (ORK.Control.CameraBlocked)
{
print("Unblock Camera");
ORK.Control.SetBlockCamera(-1, true);
}
else
{
print("Block Camera");
ORK.Control.SetBlockCamera(1, true);
}
}
}
}
I use this script to toggle Block Camera when pressing the SpaceBar. I also change the name of the camera object just to be sure that the script is working. i use the value of 'ORK.Control.CameraBlocked' to make sure that 'ORK.Control.SetBlockCamera' is actually working. but you will see that the BoxCollider component is not being disabled/enabled when pressing the spacebar.
Edit by gamingislove: Please don't post Unity projects with the full ORK version, send me the link by PM or email :)
Is your CameraController derived from MonoBehaviour?
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
In the repro project i attached a blank script derived from monobehaviour to the camera and that was working fine. So i tried this :
i have 4 gameobjects
Root>Grand Parent>Parent>Camera
I attached the empty script to Root. and in the custom controls i selected "From Root", it worked. Then i attached to grandParent instead of root, it did not work. Then in custom controls i checked both "From Root" and "On Child", it worked.
So i guess when only "From Root" is Checked, it searches for the behaviour only on the root gameobject.
So i checked both in the main project as well and it works there too.
Thanks