image

I have two custom controls, one for the player movement and one for the camera.

i use this to block both

if (!ORK.Control.CameraBlocked)
{
print("Block Camera");
ORK.Control.SetBlockCamera(1, true);
}
if (!ORK.Control.Blocked)
{
print("Block Controls");
ORK.Control.SetBlockControl(1, true);
}


and this to unblock both

if (ORK.Control.CameraBlocked)
{
print("Unblock Camera");
ORK.Control.SetBlockCamera(-1, true);
}
if (ORK.Control.Blocked)
{
print("Unblock Controls");
ORK.Control.SetBlockControl(-1, true);
}


when blocking "Block Camera" and "Block Controls" are printed. When unblocking, "Unblock Camera" and "Unblock Controls" are printed. Since these are printed inside the 'if' that means OR.Control.CameraBlocked is returning correct values. But in game, the movement is blocked but camera controls are not.
AdvancedWalkerController gets disabled but CameraController doesnt.

The custom control i set up is Camera should be blocked when i use SetBlockCamera, the behaviour "CameraController" is placed on the parent of the parent of the camera object, hence i checked "From Root".

image

Did i make a mistake somewhere? I even tried disabling 'Camera' component or 'AudioListener' component on the camera gameobject itself (unchecked From Root for this), still it isnt working. Let me know what else i should try.
  • edited February 2
    Based on the info I'd say that the components are on child objects of your camera, so you should enable On Child Object in the custom control settings.
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • the components are not on child objects. in the screenshot provided you can see that the Camera gameobject with the "MainCamera" tag has a parent called "CameraTarget", that again has a parent called "CameraControls". the "CameraControls" gameobject has the component called "CameraController" controlling the camera movement.
  • edited February 3
    So ... the camera is a child (down the hierarchy) of the game object with the control components on it?

    In that case, also use the From Root option (and On Child Object), since ORK gets the camera via the Camera component.
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • As shown in the screenshot and text of the opening post, From Root is checked.
  • Hm ... the only other thing I can think of is that the name of the component's class is different than CameraController, but you're probably aware of that the name displayed in the inspector and the actual class name don't always match.

    Is the camera control actually blocked by ORK at some point in the game, e.g. by a game event or battle?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited February 3
    the component class name is correct "CameraController", but i see that it is under a namespace. does that matter? Nmae space is CMF, should i use "CMF.CameraController" as the component/Behaviour name in Custom Control?

    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?
    Post edited by BadlySynced on
  • No, that shouldn't matter.

    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.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • 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?

    I havent actually tested the issue in a separate project. i will test it in a blank project.
  • Ah ... yeah, that could be the issue.
    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).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited February 3
    My camera is spawned later, but Camera.main returns the correct camera. i checked by printing the name of the parent of Camera.main. So if you cant think of anything else, i will try to create a small project that can reproduce the issue.

    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);
    Post edited by BadlySynced on
  • edited February 3
    ORK.Game.Camera references the camera used by ORK, but since it's set on scene load it's most likely not your camera, since it's spawned later.

    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);
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited February 4
    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
    Post edited by BadlySynced on
  • edited February 4
    But here is a repro project anyway
    image

    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 :)
    Post edited by gamingislove on
  • Colliders don't work for this, as they don't derive from the Behaviour class in Unity (which e.g. MonoBehaviour derives from), which adds the enable/disable functionality to components. For whatever reason, colliders do their own thing, directly deriving from Component and implementing their own enable property.

    Is your CameraController derived from MonoBehaviour?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Please don't post Unity projects with the full ORK version, send me the link by PM or email :)
    Understood.
    Is your CameraController derived from MonoBehaviour?
    Yes it is.



    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

    image

    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
Sign In or Register to comment.