Troubel with the rotation/movement

Started by clown611, February 12, 2017, 11:14:37 PM

Previous topic - Next topic

clown611

Hi again friends. I have some problems with my flying spaceship. The goal is to fly around in space by rotating up,down,right. I have limit the spaceship on the x so it wont rotate because I had some camera issues when it did that. I start with posting videos of my problem.

https://www.youtube.com/watch?v=E4LPfoJZoxQ&feature=youtu.be

This is the spaceship moving along the Y.

https://www.youtube.com/watch?v=dIpUXWer5as&feature=youtu.be

And here it is moving along the X.

But when I tries to combine the following methods it goes like this.

https://www.youtube.com/watch?v=LR7vk2gSTkA&feature=youtu.be

I think I understand the problem and I think I have to rotate the spaceship so it's straight before I make it go up and down.
This is my code:

  if(rotatingUp){

            counter++;
            rabbit.rotateX(-0.01f);
           

            if(lastY > mostUpSpaceShip){
                isRotatingDown = true;
                rotatingUp = false;
                moving = true;
            }

if ( rotatingRight){
            rabbit.rotateAxis(c.getYAxis(),-0.01f);
  if(lastX > rightOfSpaceShip){
                rotatingRight = false;
                moving = true;
            }
}

clown611

Basicly im wondering how to straiten up the ship after turning so it can go straight up and down. I also like random tips.

EgonOlsen

Just replace this


rabbit.rotateX(-0.01f);


by something like


rabbit.rotateAxis(rabbit.getXAxis(), -0.01f);


And while you are at it, I suggest to change the y rotation to


rabbit.rotateAxis(rabbit.getYAxis(), -0.01f);


to decouple it from the camera.

clown611

#3
I played around with it but not quite enough since im in school it worked much better. Ty for the fast answer. But I still have a problem with going up and then to the sides or the other way around. Since I still have some rotation I will not go straight up but in wacko angle. I can explain it better when I get home from school. But im wondering if there is a way to reset the ships side to side turning-angel when im turning up or down.

clown611

https://youtu.be/ogQmk16mD80

Alright im home. This is the result I got out of this. It worked out pretty good I just need to reset the rotation so the ship is straight after turning. I would like not to bug you guys so much but I have googled and looked into some exampels but I dont know how to do it.

EgonOlsen

What am I seeing there? This other rotating tie-fighter than constantly blocks the view confuses me. Maybe we should take one step back: What exactly do you want to do? From my understanding, the smaller tie fighter is supposed to rotate up/down if one swipes up/down and left/right if one swipes left/right. That's it...or isn't it?`
If so, I'm not sure what this video shows, because the tie fighter clearly seems to rotate around Z as well (which is shouldn't...or should it?) Or is the tie figther stable and the camera somehow causes this!?

clown611

#6
ok I agree that the video was bad. But the real question is how do I straightenup the ship from the rotation on only the x-axel, so I can send it straight up.

https://youtu.be/PzQqUwYXbxQ

I made a new video that maybe can explain my problem better.

EgonOlsen

I see your point (at least I guess so...), but I'm not sure what you are doing. If all you are doing would be to rotate around X and Y axis on touch and place the camera right behind the ship without any interpolation of anything, there would be no need to re-orientat anything in the first place.

clown611

ok boss I get the point. Somewhere I made a blunder, I shall search and rewrite the code. But if I fail I will crawl back to you.

clown611

#9
Hi again boss. I had to put on my thinkinghat and rewrote the code a couple of times. And now it works. I cant say I really know what I changed to make it work, but I guess I had some latenightcode that was blocking my success. Thanks for your help.

EgonOlsen