c# - Rotated an model in Unity? -


i bulid project when if :

  1. user swipe left model model should rotated left.
  2. user swipe right model model should rotated rifgt.
  3. user swipe down model model should rotated down.
  4. user swipe model model should rotated up.

what did till :

add 3d model in front of camera. made c# file.

now need basic code can make rotated on swipe. how run project in phone.

here basic code come after build first c# file of model :

void start()  } void update(){} } 

you can use rotate achieve rotation of model (see rotate documentation)

then use this example detect swipe in each direction.

you can try this:

var speed = 0.1; function update () {     if (input.touchcount > 0 && input.gettouch(0).phase == touchphase.moved) {          // movement of finger since last frame         var touchdeltaposition = input.gettouch(0).deltaposition;          // move object across xy plane         var rotationvector = new vector3(touchdeltaposition.x, touchdeltaposition.y, 0);         transform.rotate(rotationvector * speed, space.world);     } } 

Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -