c# - Rotating object breaks limitations/Bounds -


i use following logic rotate object around object , set conditions not exceed 90 degrees or under 1.

protected void rotationbounds(){  brotatedown = true;  brotateup = true;  if (_cannontube.transform.rotation.eulerangles.z >= 90)      brotateup = false;  if (_cannontube.transform.rotation.eulerangles.z <= 1)      brotatedown = false;  } 

this allows me stop the rotation in direction once condition hit. apply rotation following mouse movement controls:

protected void rotatecannonmouse(){ if (input.getkey ("mouse 0")) {         if (input.getaxis ("mouse y") > 0 && brotateup == true && brotatedown == true           || input.getaxis ("mouse y") > 0 && brotateup == false && brotatedown == true) {                     transform.rotatearound (_spherebase.position, -transform.forward,                     input.getaxis ("mouse y") * 15);            }          if (input.getaxis ("mouse y") < 0  && brotateup == true && brotatedown == true          || input.getaxis ("mouse y") < 0  && brotateup == true && brotatedown == false) {                      transform.rotatearound (_spherebase.position, -transform.forward,                       input.getaxis ("mouse y") * 15);        } } 

the following functons called in update method.

  void update () {     rotatecannonmouse();     rotationbounds();   } 

my question/problem if move rotate object @ slow/ medium speed conditions hit , expect. if rotate object fast break through conditions , mess rotation. has came across problem before? thinking maybe update method isn't iterating quick enough or i'm rotating object fast skips bounds values?

thanks in advanced

collect data, calculations , checks , rotate if neccessary. doing kinda backwards. first rotate , try clean mess. sure can make work, hardest way no reason or gain.

just store return value of input.getaxis("mouse y"), add calculated (or stored) current rotation, check if within bounds (or clamp it) , then, in end, decide if , how far rotate.

(also dont need == boolean, either true or false -> if(abool == true) same if(abool) , if(abool == false) same if(!abool). ofc not wrong, makes hard read)


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -