I'm trying to work through the tutorials and I can get players to spawn in, my problem is my camera's script to follow the character wont register because the player did not exist when the scene first starts. The camera isn't a child of the players character because of how I have it set up, so how is it that i can spawn the camera in after the player has spawned in? I've been trying several ways and nothing seems to spawn the camera.
  • You can fix this by adding a simple script to your camera, such as this:

    using UnityEngine;
    using System.Collections;
    using ORKFramework;

    namespace MyGame
    public class CameraSetup : MonoBehaviour
    private MyCamera _myCamera;
    private GameObject _player;

    void Start()
    _myCamera = GetComponent<MyCamera>();

    private IEnumerator GetPlayer()
    _player = ORK.Game.GetPlayer();
    yield return null;
    while (_player == null);

    _myCamera.Target = _player;


    You can leave the camera in your scene; when it initializes, it starts the GetPlayer() coroutine, which will keep running until ORK has spawned the player. I don't know which camera control script you're using, so it might use a method to set the target rather than assigning to a property. This should be enough to get you started; I'm sure there are some corner cases where you'd need to run the GetPlayer() routine again.
  • ah, i didnt know if there was simply an ork command to drop the camera in or not, as it auto targets on load.
  • What is the best way to get a working MMO type camera? A good example would be like World of Warcraft. I have found this script to do something like that.

  • Check out this how-to on adding custom controls.
    If you're enjoying my products, free updates and support, please consider supporting me on patreon.com!
  • Yea, I have done that. I used the custom controls for Third Person Controller from Opsive. I tried using that script but it's not working.
  • There must be others that are looking for the same thing that I am. Anyone?
  • @GearedGeek, if you're talking about the sort of camera where you can move the mouse pointer around the screen and you hold the right mouse button to move the view around, you just need to use the TPC Camera Controller's "RPG" state. Just drag it up to the top of the stack:


    Then on the UnityInput component on your player prefab, uncheck "Disable Cursor."

    If that's not what you're looking for, then never mind. ;-)
  • Thanks for that. I was talking about without TPC.
  • We'll need a bit more info on what's not working to help you :)
    If you're enjoying my products, free updates and support, please consider supporting me on patreon.com!
  • my character movement script is based on camera direction, and the camera is able to do full 360 degree motion for flight. The problem with the camera being a child is that it will bounce around with the characters motion.
    I was just going to import the character with other software like playmaker when the character drops in so I can set the camera settings to the player, but I'm thinking if I do that, some of the settings from Ork for camera settings wouldnt work at all.
  • Why isn't it possible to have the camera already in the scene instead of spawning it after the player?
    Anyway, you can always register control components in ORK through the event system (Add Control Component node), e.g. using an autostart event interaction on the camera you spawn.
    If you're enjoying my products, free updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.