Forum rules - please read before posting.

advice on running AC Action from script.

Hi, I've been using some actions directly through scripting. Like so:

//all this block of text goes into a custom method, along with others
ActionCharFace actionCharFace = ScriptableObject.CreateInstance<ActionCharFace>();
actionCharFace.isPlayer = true;
//actionCharFace.faceType = CharFaceType.Body;
actionCharFace.faceObject = MainCam.gameObject;
actionCharFace.Run();

Till now, all of the ones I've tried have worked perfectly (camera crossfade/switch, manage systems, player constrain and plenty others), and it's great for automating complex series of actions, but I cannot get the ActionCharFace to do it's thing. Basically, what I want is to make the character (Player,Npc,etc) face the camera automatically (by calling the method from a loop/coroutine when appropriate). I've tried providing the script with the gameobject from all my cameras, and the MainCamera (like below), but no matter what I do nothing happens. And I'm fairly certain that the code is being reached fine (I've put some debug.logs).

public static MainCamera MainCam;
//third person cam and travel cam
public static GameCameraThirdPerson CloseUpCam;
public static GameCamera TravelCam;

MainCam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<MainCamera>();
CloseUpCam = FindObjectOfType<GameCameraThirdPerson>().GetComponent<GameCameraThirdPerson>();
TravelCam = GameObject.Find(TravelCamName).GetComponent<GameCamera>();

Am I missing a parameter/variable that needs to be set, or like I'm guess am I just using it wrong? (because, this same camera references are working just fine with camera crossfade)

Comments

  • edited August 2016
    Nevermind... I was rally missing a parameter. Had to read the script again to notice I was missing char.ToMove, so all I had to add was:

    actionCharFace.charToMove = GetComponent<Char>();

    And now it works, lol. Maybe I'll post about this in the wiki during the week :D. I'm sure I remember others wanting to know how to use AC actions from code. Anyway, cheers!
  • put a description in the wiki pls how to use the Actions from script. =D 
  • Sure :D, you can read it here.
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.