Forum rules - please read before posting.

Ultimate Character Controller - AC player prefab total integration (Incomplete Guide)

PART 1:

As many other users of AC, I found the same problems. UCC is quite tricky.

I don't know if how many people has solved this before, but as there is no guide around, I'll post it here: . After many headaches I found the formula to be able to use UCC as an AC player (Spawned via player AC prefab, using Actionlists as "use player", (like animations, move...), saved and loaded via AC, loaded, everything working). No code required, at least using Playmaker.

There is a lot of little details, but I'm trying to cover them, and if anyone needs this to work and can't do it with this little guide, I'll explain any more detail further.

This guide takes into account that you already know how to work well with the current AC-UCC integration, and that you understand how UCC works.

The basics. First,

Let's define what is UCC working in Optimal condition:
-Camera anchor is always the same
-All presets apply on the character when playing; All presets apply to the rest of character components. All presets apply to the UCC camera, etc. References don't break (camera, canvas, "game" (That controls Kinematic Object Pool, State Manger, very important components and tricky, etc)
-It is always the same when starting the game, loading the game, IK don't break, Presets don't break, Camera don't break... and preferably with a quick way to spawn the player on any test level in order to test correctly the final product.

So one need 4 UCC components, Let's go over them first.

-Player (UCC Character with the AC integration)
-"Game" (UCC game object manager)
-UCC Canvas (Is optional, but if you want the crosshairs or messages, need to be controlled correctly; Incorrect referenced crosshairs will break the game not even allowing to move the camera)
-UCC Camera (That if playing First Person, will have anchored objects created on runtime in the first scene that the character is loaded)

Usually, the only way to get the Optimal Condition is have them on Scene spawn level. (And the only one suggested by Opsive). (So, they're spawned before the scene logic starts. I guess like the Start Action list from AC).
This leds to a lot of problems trying to easy make a game with AC, but there is a way to fix it.
I first started trying to solve this with having a AC Main Scene only with the 4 components, and load levels as AC subscenes additive, but that leads to another group of problems (to difficulty to work with AC on the subscenes, to differences between Editor/Build on Unity, etc). So I worked on finding the way to use the UCC character as an AC player prefab. And this is the formula:

Note 1: Many components need to be assigned/spawned in the correct moment; Trying to reassign afterwards, wouldn't work.
Note 2: I use playmaker to assign parameters. Player has a FSMglobalvariable (Global Player) that I use to assign everything on start and for later use. Use your method of choice.) Assigning stuff On Start, and sometimes activating something and assigning before "Game" component do its thing, its important to keep things working (See UCC canvas, for example). Also... Playmaker integration has some good FSM done already to integrate AC and UCC, but nothing that you cannot code itself on actionlists (I guess).

So, here's the way to make the 4 UCC components on a Total integration with AC:

-Player (UCC Character with the AC integration) is a prefab, and is the AC player prefab. No further components needed inside. (Well, yes, if you want to improve the integration, like Remember scripts for UCC stuff).
-I still don't know if Player switching can be used. Probably yes, but the integration is already paper thin, that's Nightmare mode.
-Once the player appear, shouldn't go away never.
-Never deactivate the UCC components. Use Enable/Disable Input events to control if it can move. If you need to block it in other ways other than describe it in the UCC integration, use UCC states/abilities.

-UCC camera Stored in a prefab, with a Don't Destroy on Load.
The first thing you'll make when start a game, is to Spawn the camera. If the camera is on scene level, it will not work, because it will be searching for other components before its time to do it.
You don't need to assign it to the current AC camera yet. UCC camera needs to be with the Init character on Awake Unticked, Autoassign anchor.
1) In runtime, you need to assign at start the UCC camera to the player (For example, the playmaker action Assign Character is made for that).
2) The camera cannot be an AC global variable prefab. Needs to be instanced and remain in game for the rest of eternity. You can reassign the camera with an Actionlist Starter on the camera to assign current camera, so when loading a game, AC doesn't need to know where is the camera; the camera will tell to AC.
3) Camera is quite specific due that generates the First person object childs... That's the reason why you can only spawn it at the start of the game, and can't be used from the prefab, only from the instance.

-"Game" Component - Present on the First Scene ever, with a Don't destroy on Load component.
Make it a prefab 'because you'll be spawning it a lot for game testing purposes, but it really only need to appear on the first scene where the player appears. With the Don't Destroy and the the rest of the UCC integration explained, it will keep working during scene changes, and when Saving and Loading. It will not work in other ways. (like being spawned).

-UCC Canvas, Controlled via AC.
(Optional as described before, but if you want to use it, you need to set it right)

Appear Type: Manual, Enabled On Start. Once is correctly spawned, you can turn it off/on as any AC menu.

Canvas parts need to be assigned on Start to the Instanced player. (Just those fields that are set up on scene level usually), I'll use Playmaker examples.

Not enough tested: UCC canvas Shouldn't be turned off when Saving. So you cannot test it with the Crossfade default Save menu.

Some parts of the canvas need to be activated before assigned. "Game" deactivates what it is not shown. and therefore when you want to assign them later, you will not be able to do it.
For example:
Crosshairs,Slots, Persistant Items FSM: On start: Assign Player
Health, Breath FSM: On Start: Assign Player (it will find automatically the atribute monitor).
Messages, Health Flash Monitor, Others FSM: On Start: Enable GameObject (the specific component), Assign Player (After the On start, Game will deactivate it, and would not let to assign it later).

NOTE: All this steps need to be exact, or "Game" component will break stuff, or spawn on its own breaking stuff, or Crosshairs will break the camera... Etc.

Let's go to Part 2.

Comments

  • PART 2:

    Summary:
    -player on AC player prefab,
    -camera instantiated on first scene with don't destroy and assign mechanisms,
    -the UCC game engine not instantiated, but present on first scene but with Don't destroy on load),
    -(Optionally) UCC canvas monitors menu controlled via AC but enabled on start and assigned in a correct way before game starts (you can turn it off after has been correctly assigned and before you Fade In the camera)

    How to make a game with all this complication:
    Of course each level will need a lot of playtesting while it is build.
    0. Make the true First Scene "On start" Actionlist that will be present on the real game and Builds, this one will spawn the UCC Camera and assign it for the first time via parameters.
    1. Make an Actionlist for "On start" for each level that is when you are changing levels. (Needs nothing specific if you have followed all the guide).
    2. Make an Test Actionlist for "On Start" for when your just testing a level. this one spawns the UCC camera.
    3. When you're testing a level, put the correct actionlist, and Drop the "Game" Component on scene.
    4. When you finished testing the level and want to test a build, change the actionlist, and delete the "Game" Component from that scene.

    Thing is; Works. The loaded state of the Integration is exactly the one from the saved one. So perfect. You can use "Is Player" actionlists, AC will remember player position, you can make your regular gameplay switching scenes or additive scenes without worring about UCC, just treating the game like a regular AC player... etc.

    Perfect? Not yet.

    Depending on the exact way you spawn the character the first time, camera anchor will be a bit off. When you load a game, the camera anchor will change, but it will never change again. So you need to spawn the character correctly (I have actionlists where it spawns correctly, other where not, I have to still work on that. But knowing that saving and loading always give the same results, means that the system works.

    And for a perfect integration, we need Remember custom data, and I'm null at coding so, help is welcomed.

    Please, anyone with further knowledge share it, and if anyone tries this way and found a problem I'll try to see if I can explain the procedure better.

    Myself, as I finally been able to correctly make a system that works, I'll keep asking if some determinate actionlists may break the player when use it on it (For example, Teleport is supossed to work, but I don't know if there are other that may break the controller, so time will tell.

  • Update: Finally sort out the strange changes on Camera Anchor spawning in different levels, before Load (and probably future problems when scene changing.)
    After this fix, now the UCC player is functionally always the same, on Spawn and on Load.

    I'm not sure if problem was not on Teleport, but at least looked like was on PlayerStart Teleport part.

    As the GameEngine that AC generates on scene (for some reason, maybe is just me), is always "Two D" and turning "Unity 2d", instead of "Three D" and "World Space". Once change that on the GameEngine of all scenes, the Integration looks fully stable spawning the UCC character with exactly the same camera anchor as is later loaded, 100% of times.

  • As the GameEngine that AC generates on scene (for some reason, maybe is just me), is always "Two D" and turning "Unity 2d", instead of "Three D" and "World Space"

    This is in the GameEngine's Scene Settings component?

    The "Moving And Turning" Inspector field there should only have an effect if the "Override Camera Perspective" field above it is checked - otherwise, the scene should default to the Settings Manager field of the same name.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.