Demon_ Gold (three drop item presets, one-off object tool)

Source: Internet
Author: User

Tools to connect objects

usingUnityengine;usingSystem.Collections; Public classTool:monobehaviour {floatHor;    Vector3 Movedir;  Public floatMovespeed =3f; intScore =0; voidUpdate () {Hor= Input.getaxis ("Horizontal"); //get move Direction vectorMovedir = Hor *Vector3.right; //MovingTransform.position + = Movedir * Time.deltatime *Movespeed; }    voidOntriggerenter (Collider other) {if(Other.tag = ="Gold") {Destroy (other.gameobject); Debug.Log (++score); }    }}

Create three presets for a drop body

usingUnityengine;usingSystem.Collections; Public classGoldcreater:monobehaviour {//Coin Preset Body     PublicGameobject Goldprefab; //time interval to generate coins     Public floatInterval =1f; //Timer    Private floattimer; //index number    Private intindex; voidUpdate () {// Timer TimerTimer + =Time.deltatime; //Timing Complete        if(Timer >=interval) {            ///TODO: Generate coinsGoldinit (); //timer reset to zeroTimer =0; }    }    /// <summary>    ///Generate coins/// </summary>    voidGoldinit () {//Sub-object index number (random)index = Random.range (0,3); //Build LocationVector3 Initpos =transform.        Getchild (index). Position; //Generate coinsInstantiate (Goldprefab, Initpos, quaternion.identity); }}

Demon_ Gold (three drop item presets, one-off object tool)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.