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.
using UnityEngine;
using System.Collections;
using ORKFramework;
namespace MyGame
{
public class CameraSetup : MonoBehaviour
{
private MyCamera _myCamera;
private GameObject _player;
void Start()
{
_myCamera = GetComponent<MyCamera>();
StartCoroutine(GetPlayer());
}
private IEnumerator GetPlayer()
{
do
{
_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.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Then on the UnityInput component on your player prefab, uncheck "Disable Cursor."
If that's not what you're looking for, then never mind. ;-)
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
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.
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, updates and support, please consider supporting me on patreon.com!