C # Add special effects,

Source: Internet
Author: User

C # Add special effects,

Public class BulletMove: MonoBehaviour {

Public float Speed = 5f;

Public Transform Fx;

// Use this for initialization

Void Start (){

// Delete yourself in 5 seconds

Destroy (gameObject, 5f );

}

// Update is called once per frame

Void Update (){

// Move along its own Z axis Coordinate System

Transform. Translate (-Vector3.forward * Speed * Time. deltaTime );

}

/// Contact

/// <Param name = "other"> </param>

Private void OnTriggerEnter (Collider other ){

// The Bullet collided with the meteorite.

Var stone = other. GetComponent <Stone> ();

If (stone! = Null ){

Stone. Hit ();

// Destroy itself

Destroy (gameObject );

If (Fx! = Null ){

// Generate special effects

Transform fx = Instantiate (Fx );

Fx. position = transform. position;

// Delete yourself in 2 seconds

Destroy (fx. gameObject, 2f );

}

}

}

}

Related Article

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.