Unity role Resurrection and restart game

Source: Internet
Author: User

When the author writes the game, he still needs to think about how to start the game again and how the character will be resurrected.

Most will use this method instead of the game to restart the application.loadlevel ("xxx Scene") .

But the resurrection of the character has to be written in its own code to change the component to a certain state.

Re-play:

Application.loadlevel ("xxx scene") = Start the game again

Components. Restore initialization State () + component. Restore initialization State () + component. Restore initialization status () + ... = restart the game

Role Resurrection: Nothing but some roles revert to a specific state

usingSystem;usingUnityengine; Public classGame Control Center { Public BOOLStart Game =false;  Public voidStart Again () {Application.loadlevel ("XXX Scene Full component restore to initial state"); }    //Complete the Role Resurrection function     Public voidrole Resurrection () {Protagonist information component. Restore continue game state ();        Enemy components. Restore continue game state ();        Other components. Restore continue game state (); Start the game=true; }    //The actual programming author is such a%>_<%     Public voidrole Resurrection 2 () {lead information component. Blood value=Ten; Enemy components. Collider. eanble=true; Enemy components. Start attacking=true; //and so some xxxx work, relatively scattered            }}

Role Resurrection the first way to make the code intuitive!

Introduce the following memo design mode: http://blog.csdn.net/zhengzhb/article/details/7697549;

Unity role Resurrection and restart game

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.