### Author Topic: Troubel with the rotation/movement  (Read 1628 times)

#### clown611

• byte
• Posts: 34
##### Troubel with the rotation/movement
« on: February 12, 2017, 11:14:37 pm »
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.

This is the spaceship moving along the Y.

And here it is moving along the X.

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

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

• byte
• Posts: 34
##### Re: Troubel with the rotation/movement
« Reply #1 on: February 13, 2017, 07:42:57 am »
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

• Posts: 11968
##### Re: Troubel with the rotation/movement
« Reply #2 on: February 13, 2017, 08:47:55 am »
Just replace this

Code: [Select]
`rabbit.rotateX(-0.01f);`
by something like

Code: [Select]
`rabbit.rotateAxis(rabbit.getXAxis(), -0.01f);`
And while you are at it, I suggest to change the y rotation to

Code: [Select]
`rabbit.rotateAxis(rabbit.getYAxis(), -0.01f);`
to decouple it from the camera.

#### clown611

• byte
• Posts: 34
##### Re: Troubel with the rotation/movement
« Reply #3 on: February 13, 2017, 11:41:45 am »
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.
« Last Edit: February 13, 2017, 01:51:20 pm by clown611 »

#### clown611

• byte
• Posts: 34
##### Re: Troubel with the rotation/movement
« Reply #4 on: February 13, 2017, 06:14:20 pm »
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

• Posts: 11968
##### Re: Troubel with the rotation/movement
« Reply #5 on: February 13, 2017, 08:06:27 pm »
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

• byte
• Posts: 34
##### Re: Troubel with the rotation/movement
« Reply #6 on: February 13, 2017, 09:24:15 pm »
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.
« Last Edit: February 13, 2017, 11:20:25 pm by clown611 »

#### EgonOlsen

• Posts: 11968
##### Re: Troubel with the rotation/movement
« Reply #7 on: February 14, 2017, 08:36:57 am »
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

• byte
• Posts: 34
##### Re: Troubel with the rotation/movement
« Reply #8 on: February 14, 2017, 09:02:36 am »
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

• byte
• Posts: 34
##### Re: Troubel with the rotation/movement
« Reply #9 on: February 14, 2017, 08:17:05 pm »
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.
« Last Edit: February 14, 2017, 08:25:18 pm by clown611 »