[Unity 3D] Study Notes forty-five: Game instances-kill the wall, unity Study Notes

Source: Internet
Author: User

[Unity 3D] Study Notes forty-five: Game instances-kill the wall, unity Study Notes

Use this game instance to summarize all the previously reviewed knowledge about physical engines. In the game, a ball shell is sent to kill the front wall. A rigid body component is added to both shells and walls, a particle system is bound to shells, and five different colors are added to the shell particle animation to display the moving track.

Using UnityEngine; using System. collections; public class Script_06_14: MonoBehaviour {// shell object private GameObject obj; // quasi-heart Texture public texture Texture; void Start () {// obtain shell object obj = GameObject. find ("Sphere0"); // hide the default Mouse icon Screen. showCursor = false;} void FixedUpdate () {// click the left mouse button and then if (Input. getMouseButton (0) {// create a Ray from Camera position to mouse select position ray Ray = Camera. main. screenPointToRay (Input. mousePosition); RaycastHit hit; // determines whether the rays intersect with the game object if (Physics. raycast (ray, out hit) {// make sure the game object is a wall if (hit. collider. name = "Cube") {// calculate the distance between the shell and the target point. Vector3 ction = hit. transform. position-obj. transform. position; // fired shell obj. rigidbody. addForceAtPosition (direction, hit. transform. position, ForceMode. impulse) ;}}} void OnGUI () {// draw a quasi-Central Rect rect = new Rect (Input. mousePosition. x-(texture. width> 1), Screen. height-Input. mousePosition. y-(texture. height> 1), texture. width, texture. height); GUI. drawTexture (rect, texture );}}
After running:


The above is a simple description. If the reader wants to make such an effect, I will upload all the source code to the space when writing all the learning summaries. If you need it now, please send a private message. Thank you.


Questions about unity3D Game Development

I have been familiar with virtools and unity, and I feel that the engine has its own advantages. As long as I master all of them, I personally feel that unity is in line with my style. Not very gorgeous, but all game functions can be implemented. There are a lot of resources available for download in the unity store, and it is also very convenient to make 2d games.
You can also export your own game to your mobile phone. If you are narcissistic, you will feel satisfied. You can combine art and programming very well. There are very few talents in this field. It is not difficult to learn about unity. As long as you complete several game production examples with video, you can achieve most of the functions. To be proficient, you must study it.
There are many cracked versions of unity on the Internet, and 3.0 is enough. The cracked version is still stable. Occasional problems.
I feel that about 5000 of my laptop can meet the requirements, and I need to use a desktop computer to make a precision model.

[Unity3D] mobile 3D Game Development: how to use gravity sensing in Unity3D

Wang wanghai's laboratory, Shanghai laboratory-various graphics experiments, data structure experiments, and other trivial little notes are all gathered here for 0-various graphics experiments and data structures the lab and all other trivial notes are gathered here for 0 error (s ), 0 warning (s) the arrival of this magic moment error (s), 0 warning (s) the arrival of this magic moment learning Unity script is recommended: unity3D indexing gravity sensing is very common in mobile game development. Unity3D is a collection of gravity sensing related content. A simple JS script demonstrates the use of gravity sensing. CSDNGravity. js: // object texture var round: Texture2D; // The x y coordinate var x = 0 displayed on the screen; var y = 0; // maximum x y range displayed on the Object Screen var cross_x = 0; var cross_y = 0; function Start () {// initialization value cross_x = Screen. width-round. width; cross_y = Screen. height-round. height;} function OnGUI () {// The overall x y z gravity sensing gravity component GUI is displayed. label (Rect (0,0, 480,100), "position is" + Input. acceleration); // draw the object GUI. drawTexture (Rect (x, y, 256,256), round);} function Update ( ) {// Modify the object position based on the gravity component. Multiply the value by 30 here to make the object move faster x ++ = Input. acceleration. x * 30; y + =-Input. acceleration. y * 30; // avoid an object exceeding the screen if (x <0) {x = 0;} else if (x> cross_x) {x = cross_x ;} if (y <0) {y = 0;} else if (y> cross_y) {y = cross_y ;}} the Input here refers to the Input in Unity, acceleration is its gravity, and x and y represent its gravity. After creating the image, you only need to add the texture image: 12

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.