Forum rules - please read before posting.

using a ready made script in AC

2»

Comments

  • Also supports particle effects - way cool!image
  • Yes !! unfortunately we have different packages I can't understand how mine would work because there is no Class called Esplode but one called ClickOrTap and yet it does explode. yours looks better though but spending another 17 
  • I bought this second type of Exploder and it is by far superior to the one I bought first. Now I can do what you showed in the pictures above. 
    So I paid 34 € for both !! 
    Fewer beers this weekend for me 
  • Poor Brain!
  • edited August 2015
    I've been wanting to do this a lot after playing Day Of The Jackass! :-)
  • Help Please !!
    I used this script in Unity before going to AC and I've been tying to get it compatible in AC. I followed tutorials but not being a decoder ....
    Can you charitable people add to this script so that I can use it with the wonderful AC????
    ======================================

    using UnityEngine;
    using System.Collections;

    public class Spawner: MonoBehaviour {

        public GameObject prefabA;
       
        static int count = 0;
        static float lastTime = 0;
        public int showCount = 0;

        void Start()
        {
            lastTime = Time.time;
        }

        void Update()
        {
            if(count < 200)
            {
                bool alt = Input.GetButton("Fire1");

                if (Time.time - lastTime > 0.1f)
                {
                    if(prefabA != null && !alt) Instantiate(prefabA, new Vector3(0,0,0), Quaternion.Euler(0, 0, 0));
                    lastTime = Time.time;
                    count++;
                    showCount = count;
                }
            }
        }
    }


    ===========================================
  • The script runs fine (as written) in AC - what are you trying to make it do?
  • Sorry it's a stupid question, but you've defined "Fire1" in your Input Manager, right?
  • Sorry forget about the Fire1, just comment it out.
    I place this script in a cylinder Game object and from a cutscene (startUp) I place the ubiquitous 

    SendMessage
    Object to affect: cylinder
    Method: MySpawn

    and what I expect is that the cylinder is instantiated 'count' times.
    Now I see the 'count' counting and I have this errors:
     The referenced scripts on this behaviour is missing! (yellow triangle)
    SendMessage MySpawn has no receiver! (red error !)
    and of course nothing is instantiated.


  • Looks more like something you should put on an empty GameObject. Massive Jack Daniels hangover here, so won't attempt any further explanation today, but ok if I pm you about this tomorrow? It's really more of a Unity thing than AC-related ...
  • I have two scripts that I used in my pre-Adventure Creator scenes: Spawning and detect-the-player (raycasting) and I would like to have their essence incorporated into AC. 
    Once I find a solution for one of these scripts I can 'imitate' the mechanism to the others. 
    Neither one of the above actions can be implemented in AC actions unless with a convoluted scheme.

    Sure I can wait I didn't expect an answer on Sunday... you see I am now retired and have ALL the time in the world.
  • During the weekend I made the spawning script work !! 
    Now I will try with the 'detect the player' script. A pity that there is no AC action list where a NPC can detect the Player by sight or noise only the Action NPC Follow which is not ebough
  • ..... but how do I trigger this script from my scene? right now as soon as the scene runs it spawns the objects. I tried to follow the tutorial to convert this script into an ActionList but I am having problems with it. Is there any other way to 'activate' this script with AC?
  • and again I read a message from Chris on June 2 where he recommends to use the 'interact() ' function to call the essence of the script and it works so I don't need to make it into an ActionList just the SendMessage and Method name: interact.
    Incidentally the tutorial about "Writing a custom Action " is not up to date it tells me to do things that don't exist or are changed now.
  • But there's no function by the name "MySpawn" in the script you posted.  The Send Message Action is used to call functions within a script placed on an object - you have to make sure they match.  From the sounds of it, the "cylinder" object has no script on it that includes a function by that name.

  • This script works. I place an empty game object (spawn2) and i include this script in. Then I do a SendMessage to spawn2 with a Method interact. It spawns 'count' number of objects.
     My problem now is that in spawning these objects they are renamed with the added word (clone) and whatever I want to do with them, like say, Object:Teleport the Object with the additional (clone) word is not recognized.
    ====================================
    using UnityEngine;
    using System.Collections;

    namespace AC
    {

    public class MySpawn: MonoBehaviour {
    public GameObject prefabA;
    public GameObject prefabB;
    public float SpawnArea = 0f;
    public int count = 0;
    void interact()
    {
    for(int k= 0; k< count ; k++)
    {
    if(prefabA != null)
    Instantiate(prefabA, new Vector3(Random.Range(-SpawnArea,SpawnArea),0,Random.Range(-SpawnArea,SpawnArea)), Quaternion.Euler(270f, 0, 0));
    if(prefabB != null)
    Instantiate(prefabB, new Vector3(Random.Range(-SpawnArea-5,SpawnArea+5),0,Random.Range(-SpawnArea-5,SpawnArea+5)), Quaternion.Euler(270f, 0, 0));
     }
    }
    }
    }
  • You can rename the object once you've instantiated it, but I suspect that's not what you're after.  You cannot use an object created mid-game in Actions (you can, however, instantiate prefabs using Object: Add or remove and use Constant ID scripts to reference them in Actions).

    This sounds like more of a scripting question, in which case I'd advise you post on the Unity forums for help.
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.