Shark Bomb Mini Game summary

Source: Internet
Author: User

2/3d Games:2.5D

Auxiliary plugins: native

game Making difficulty factor: Beginner

Game Tutorial URL: http://www.raywenderlich.com/4551/how-to-make-a-2-5d-game-with-unity-tutorial-part-1

1. Background adaptive (guitexture) orthogonal mode

voidStart () {guitexture GUI= getcomponent<guitexture>(); //the Pixelinset values for guitexture are://width:510 height:340//x: -255 y: -170Rect r =NewRect (); R.width=Screen.width; R.height=Screen.height; floatm =510/ -255f; floatn =340/ -170f; R.x= Screen.width/m; R.y= Screen.height/N; Gui.pixelinset=R; }

2. Control camera rotation resulting in 2.5D effect (perfect solution with mathematical knowledge)

floatAnglespan =0; voidUpdate () {//determine if the aircraft exceeds the visible range of the screen, and if it exceeds the position of the aircraft, 20 is set according to the Maincamera far .        if(Transform.position.x > -) { speed=Random.range (8f, 12f); Transform.position=NewVector3 (-20f, TRANSFORM.POSITION.Y, transform.position.z); } transform. Translate (0,0, Speed *time.deltatime); //2.5D effect Nextz possible value (initial value is 0): 2 4 6        if(Nextz >maincamera.transform.position.z) {//Author's method://Float mx = 3 * Mathf.sin (TRANSFORM.POSITION.Z/2) * time.deltatime; //float mz =-mathf.sin (TRANSFORM.POSITION.Z/2) * time.deltatime; //mainCamera.gameObject.transform.Translate (MX, 0, MZ);            floatAngle = Time.deltatime *5.7f; //change the background and camera rotation, resulting in 2.5D effectmainCamera.gameObject.transform.Rotate (vector3.up, Angle);            GameBackground.gameObject.transform.Rotate (vector3.back, Angle); //My method: Calculate the angle of each rotation of the cameraAnglespan = Maincamera.gameobject.transform.localeulerangles.y-Anglespan; floatDistance =vector3.distance (gameBackground.transform.position, mainCamera.transform.position); Vector3 ZZ=NewVector3 (-distance * Mathf.sin (Anglespan *Mathf.deg2rad),0, Distance* (1-Mathf.cos (Anglespan *( Mathf.deg2rad))); MainCamera.gameObject.transform.Translate (ZZ*time.deltatime); }

The picture on the left is the normal state when the shark is not hit, and the right is the state after the shark has been hit two times.

When the shark was hit, In order to achieve 2.5D effect, perfect to rotate the camera and background map, and move the camera, the camera and the background of the rotation to do, is to give them the same angle to rotate, but after the rotation, in order to maintain the camera's original shooting angle and the screen, how we move it, this requires a certain angle of rotation for the camera's landing point, : The location of the camera (0,0,0), the position of the background map (0,0,20)

Other trivia:

1, the role of translate: is the sign to indicate the direction, the value represents the moving distance

Transform. Translate (New Vector3 ( -10,-TRANSFORM.POSITION.Y + random.range (-4,-1), 0));//move 10 units in the opposite direction of the X-axis

Shark Bomb Mini Game summary

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.