Search code examples
unity-game-engineunityscriptunity-web-player

Control of Unity3D web player's camera


Is it possible to control the camera in a Unity3D project being played on the Web player?

I want to control the walk through of existing models using JavaScript in the web player.

I see they have API functions for calling internal functions defined within the script, but don't see any way to gain access to the camera.


Solution

  • By API, I assume you mean the SendMessage approach outlined in the documentation. That is indeed the best way to approach this. Write a script which controls your camera, expose functions you can call, and call those using the

    function ControlCamera()
    {
        u.getUnity().SendMessage("MyCamera", "Control", "");
    }
    

    approach.

    Other than that, to the best of my knowledge, there is no real exposure of a full API that lets you control GameObjects or components attached to them from JavaScript in the manner you seem to be requesting.