using Uni­tyEn­gine; using Sys­tem. Col­lec­tions;

L'Informaticien - - DEV -

pu­blic class Co­rou­ti­nesExample : Mo­noBe­ha­viour { pu­blic float smoo­thing = 1f; pu­blic Trans­form tar­get; void Start () { StartCo­rou­tine( MyCo­rou­tine( tar­get)); }

IE­nu­me­ra­tor MyCo­rou­tine ( Trans­form tar­get)

{

while( Vec­tor3. Dis­tance( trans­form. po­si­tion, tar­get. po­si­tion) > 0.05f)

{

trans­form. po­si­tion = Vec­tor3. Lerp( trans­form. po­si­tion, tar­get. po­si­tion, smoo­thing * Time. del­taTime);

yield re­turn null; } print(" Rea­ched the tar­get."); yield re­turn new WaitForSe­conds( 3f); print(" MyCo­rou­tine is now fi­ni­shed."); } }

Newspapers in French

Newspapers from France

© PressReader. All rights reserved.