Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / how to rotate ship so it's bottom is facing down?

Author
Message
qwedsa
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location:
Posted: 12th Jun 2013 06:40
after the player has locally rotated x, y, z to random values, i want to have a button that, while pressed, turns the ship so that its bottom is facing the direction of gravity (toward the planet/star)
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Jun 2013 10:37
I think that I would work out the ship direction vector first. So, if you take your ship object, store it's location, then move it back by 1 unit and store that location, you'd have a vector for the ships direction quite easily. Then, with just the ships location and your gravity source, work out a vector for the ship and the planet (or whatever) and normalize it.

That would give you 2 vectors, one that has to be adjusted to meet the other, the easiest way is probably to convert those vectors into angles for each axis. So you'd work out the X angle for the ships trajectory, and the gravity force, and adjust it to suit, then the same for the Z angle, the Y angle won't be an issue as long as the rotations are all local, it could just be left to roll left and right depending on the ships movement.

I got a fever, and the only prescription, is more memes.

Login to post a reply

Server time is: 2024-11-24 15:47:54
Your offset time is: 2024-11-24 15:47:54