Auto-Mobile AI for enemies in 3d mode

Source: Internet
Author: User

1 usingUnityengine;2 usingSystem.Collections;3 4  Public classTroll:monobehaviour5 {6 7     Private BOOLIsidel=true;8      Public floatTimer =2;9      Public intSpeed =1;Ten     Privaterigidbody rigidbody; One     PrivateAnimator Anim; A  -  -  the     voidStart () -     { -Rigidbody = This. Getcomponent<rigidbody>(); -Anim = This. Getcomponent<animator>(); +     } -      +     //Update is called once per frame A     voidUpdate () at     { -Timer-=Time.deltatime; -         if(timer<=0) -         { -             if(Isidel) -             { in                 //Walking Method - Transformtowalk (); to             } +             Else -             { the  *                 //to stand in a State $ Transformtoidel ();Panax Notoginseng             } -         } the         if(!Isidel) +         { A             //to shift the             //transform.position + = transform.forward*time.deltatime*speed; +Rigidbody.position + = transform.forward*time.deltatime*Speed ; -         } $  $     } -  -      Public voidTransformtoidel () the     { -Timer =2f;WuyiIsidel =true; the Animationtoidel (); -     } Wu  -      Public voidTransformtowalk () About     { $Isidel =false; -Timer =5f; -         intRandom = Random.range (- -, -); -Transform. Rotate (NewVector3 (0, Random,0)); A Animationtowalk (); +     } the  -      Public voidAnimationtowalk () $     { theAnim. SetFloat ("Walk",1.0f); theAnim. SetFloat ("Idle", 0f); theAnim. SetFloat ("Run", 0f); the     } -  in      Public voidAnimationtoidel () the     { theAnim. SetFloat ("Walk", 0f); AboutAnim. SetFloat ("Idle",1.0f); theAnim. SetFloat ("Run", 0f); the     } the}

Auto-Mobile AI for enemies in 3d mode

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.