Search Unity

Rotate object

Discussion in 'Project Tiny' started by whiteworld, Aug 25, 2019.

  1. whiteworld

    whiteworld

    Joined:
    Jun 24, 2016
    Posts:
    14
    Code (JavaScript):
    1. export class RatateObject extends ut.ComponentSystem {
    2.        
    3.         static degree = 1;
    4.  
    5.         OnUpdate():void {
    6.  
    7.             this.world.forEach([ut.Entity, game.IsCar, ut.Core2D.TransformLocalRotation], (entity, flag, carRotate) => {
    8.  
    9.                 carRotate.rotation.setFromAxisAngle(new Vector3(0, 0, 1), (RatateObject.degree / 180) * Math.PI);
    10.                 RatateObject.degree += 1;
    11.                 if(RatateObject.degree >= 360)
    12.                 {
    13.                     RatateObject.degree = 0;
    14.                 }
    15.                 console.log(RatateObject.degree);
    16.  
    17.                 //carRotate.rotation.setFromEuler(new Euler(0,0,RatateObject.degree));
    18.             });
    19.  
    20.            
    21.            
    22.         }
    23.     }

    I wrote this code to rotate the object , But it doesn't happen!
    why ?!