Forum rules - please read before posting.

how to Get Object material with Action List or otherwise


I get to Change Material in Action list but not Get Material. Is there a way to implement this? Can you give me a clue on how to implement it with something like the AC.kickStarter function?
After I change the Material in one object I want to be able to save the its name in a string variable for comparison later 

Comments

  • As described in the scripting guide, AC.KickStarter is not a function - it is a reference that allows you to access each of AC's scripts, i.e.:

    AC.KickStarter.settingsManager

    As storing a material's name is a need unique to your game, you must use a custom Action.  The code inside your Run function will be something along the lines of:

    string materialName = myGameObject.GetComponent<Renderer>().materials[0].name;
    AC.GlobalVariables.SetStringValue (myStringGlobalVariableID, materialName);


    Where myGameObject is the object whose material you wish to record, and myStringGlobalVariableID is the ID number of the string variable to store it to.
  • I had looked around in Internet for that solution and I didn't find it. I have used the setting/getting of variables through the AC.GlobalVariables lots of times but long line to get the material is quite complicated.... for me.

    It works, thanks.
  • I am developing a typical Memory (find pairs) project exclusively using AC because there are upteen samples out there doing it with C#.

    My project is 80% completed but I cannot find a solution because of the unavailability to store,   GameObjects. in Global variables AC. 

    When I click inside one of  the Hotspot Objects it opens up and shows its Material 'x' and then I click at another Hotspot 'z'  which shows also its material If they are equal I turn both objects invisible but I can't know which object was the first because I don't have a way to remember a GameObject  in AC.
    I have spent a long time trying to find a way out I tried Parameters , and storing the coords of the chosen Objects but to no avail.
  • You can store a GameObject's Constant ID number in an Integer variable.  If you pass an Integer parameter to a GameObject field, then that number will be used to find that GameObject via it's Constant ID number.
  • That would be nice. but can't make it work.
    I have stored the Constant Id of the GameObject  9the one I will want to make invisible later) in a variable .
    In my CheckEquality Action List (where I check if both materials are equal) I list 2 integer parameters but then you say  " If you pass an Integer parameter to a GameObject field"  but I can't let me place anything except a GameObject:

    Object:Visibility
    Object to affect: ONLY ACCEPTS GAME OBJECTS
    Visibility: invisible
  • One caveat: the Action that calls the parameterised ActionList (i.e. the one that has ActionList: Run in it) must be an asset file - not a scene-based Cutscene or the like.  You'll then be able to set GameObject parameters by ID number, as well as by GameObject.
  • I changed into an Asset file. Now in this action I have:

    ActionList:Run
    Source: Assetfile
    ActionList Asset: CheckEquality (ActionList)
    Set Parameters  ticked
    card 1:  None (GameObject)
    card 1 (ID #) 1091552
    card 2: None (GameObject)
    card2 (ID #) 1476532

    But those ID # I had to enter by hand but these will change depending on the card I click in the board . I have the individual ID# stored in a variable integer but I cannot use this variable in the above ActionList .

    Of course if I manually enter the corresponding ID# the ActioList Asset I call CheckEquality will indeed recognize those ID# as GameObjects and render then invisible which is what I want.

    In my CheckEquality action I have this:

    Parameters
    0 card 1  GameObject
    1 card  2 GameObject


  • SOLVED !! after 2 days and a complex ActionList and a parameter ActioList I have what I wanted: If the 2 cards I clicked and unveiled are the same than make it invisible and otherwisw if they are visible.
    Frankly speaking this convoluted way could have been avoided had we a Variable GameObject available.

    ;)
  • Are GameObjects and parameters actually necessary for this?  You can store materials as two string variables, alternating which one is updated each time, i.e.:

    Click Hotspot A: Material A is set in Variable 0
    Variable 0: Material A, Variable 1: Blank

    Click Hotspot B: Material B is set in Variable 1
    Variable 0: Material A, Variable 1: Material B

    Click Hotspot C: Material C is set in Variable 0
    Variable 0: Material C, Variable 1: Material B

    Click Hotspot A: Material A is set in Variable 1
    Variable 0: Material C, Variable 1: Material A

    You could then compare the two variables each time.  Would that give you what you're looking for?
  • My problem was that I have to either remove the equal Objects from the board or cover them if not equal. So it's the Objects that gave me the headache not the materials for which I used a tiny script which returns the material in a string AC.Variable as you told me how to.

    I am sure , specially you, would find a better way of doing this but after 3 days I don't want to change anything. We say "better not stir it"
    The reason I found the solution is by using an ActionList: SetParameter which can set one and only one of the 4 parameters I had at a time.....
    Thank you for your help as usual even when it is a Holiday (maybe it is not a holiday in your area)

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.