Space shooter shooting

Source: Internet
Author: User

1. Control player Movement

     Public floatSpeed =10f;  Public floatXMin =-6.5f;  Public floatXmax =6.5f;  Public floatZmin =-4.5f;  Public floatZmax =4.5f; voidfixedupdate () {floatH = Input.getaxis ("Horizontal"); floatv = Input.getaxis ("Vertical"); Vector3 Move=NewVector3 (H, 0f, V); Rigidbody.velocity= Speed *move; //limit the range of aircraft activity, this similar setting transform.positionRigidbody.position =NewVector3 (Mathf.clamp (rigidbody.position.x, XMin, xmax),0, Mathf.clamp (Rigidbody.position.z, Zmin, Zmax)); }

2. Set Boundaries (Destroy objects (bullets, enemy aircraft) beyond the boundary

DestroyByBoundary.cs script:

    publicvoid  ontriggerexit (Collider Other)    {        Destroy (other.gameobject);    }

3. Set the meteorite to rotate around itself

    float 5 ;     void Start ()    {        // random one angular speed        rigidbody.angularvelocity = random.insideunitsphere *  tumble;    }

4, the speed positive and negative control movement direction positive and negative

 Public float speed = 10f;  // Speed is positive, the object moves forward, is negative, moves backwards rigidbody.velocity = speed * Transform.forward;

Space shooter shooting

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.