July 18 Training of the Unity project encountered in the problem record

Source: Internet
Author: User

1. When you make a UI in one project and then use it in another project, you find that you cannot respond to mouse input events

Workaround: Add EventSystem in the project that uses the preset body.

2. Use Dontdestroyonload () to avoid the problem of Gameobject being destroyed after scene switching

If a scene has a gameobject named player, in order to prevent the player from disappearing when the scene switches to B, use Dontdestroyonload (player), which will cause the scene to switch back to a again, there are two players in the a scene. and two player will not disappear after a scene switch. The number of player increases as the number of times a switch back to a is increased.

Workaround One:

Create a new initialization scene before all the scenes, initialize the scene to place the gameoject used in all the scenes and add it to the dontdestroyonload, and ensure that it does not jump back to the initialization scene and avoid repeated initialization.

Workaround Two:

The gameobject is made into a pre-built body, instantiated in the script (rather than directly in the scene), then added to Dontdestroyonload, and a static Boolean variable is used to identify if it has been instantiated, avoiding duplication of instantiation.

Example code:

 Public classInitializer:monobehaviour {[Serializefield]PrivateGameobject _playerprefab; [Serializefield]PrivateGameobject _cameraprefab; PrivateGameobject _player; PrivateGameobject _camera; Private Static BOOLisinstantiated =false; Private voidInstan () {_player=instantiate (_playerprefab); _camera=instantiate (_cameraprefab);        Dontdestroyonload (_player);        Dontdestroyonload (_camera); Dontdestroyonload ( This. Gameobject); }    Private voidAwake () {if(!isinstantiated)            {Instan (); Isinstantiated=true; }    }

Note: The role of Dontdestroyonload (Object obj): obj will not be destroyed after all scenes have been switched.

3. After converting a model with an animated type of legacy to a humanoid type, the characters in the animation appear deformed:

The warning given by unity after conversion is:

Originally wanted to open the model in blender to see, but each import model blender will "not respond" ... Not resolved.

4. Simulate the blood bar with a slider

By deleting the slider handle slider area node, setting the slider's scale value to set the bar size, set the slider under the Fill Area node and its child nodes fill on the left and right values of the Rect transform component is 0.

5. Wild Monster AI

Ai ideas: Wild monsters have different behaviors, such as idle, chasing players, launching different attacks, injuries and death. The first three types are active and the latter two are passive behaviors. Assign a weight to each active behavior. The behavior patterns of wild monsters are as follows: Idle ... The player enters the detection range and chases the player ... The player enters the effective area of the partial attack mode, chooses the effective attack according to the weight randomly or continues to chase ... Players enter the effective area of all attack modes, randomly select the attack mode according to the weights ...

Assigning time to each behavior (equal to the duration of the animation that corresponds to the behavior), when the Wild Monster is in a behavior, plays the corresponding animation, changes the transform of the wild Monster (if necessary), only the passive behavior can interrupt the current behavior.

When the behavior is interrupted frequently the bug is prone to be fixed.

6. The protagonist locks the monster and moves around sometimes "drops" from the map, not fixed.

7. It should be shown that a few seconds later disappears after the box build flashes (normal on play) for unknown reasons.

8. The sound of the sword is not abnormal when it is played locally, and when added to the game there is "bared" noise, unknown reason.

July 18 Training of the Unity project encountered in the problem record

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.