1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

# Gravity aligning thrusters

Discussion in 'Programming (In-game)' started by firestorm29, Nov 27, 2018.

This last post in this thread was made more than 31 days old.
1. ### firestorm29Trainee Engineer

Messages:
7
Hello, I wanted to try and create a script that uses thrusters on rotors to rotate them to match gravity for a modular miner I was going to try and build. I was wondering if anyone here had tried a project like this and how you went about it, since I was thinking about making it where you feed the gravity vector into the rotor and have it rotate the thruster to match the angle (or the inverse of it).

I attempted to look at the Gravity Aligned Camera script to see how he was rotating the camera and I wasn't able to fully understand what was going on and trying to find documentation on how to use scripts wasn't very good.

2. ### noemdeixaTrainee Engineer

Messages:
1
Hi, I've just started playing and this may not be the best solution but I hope it helps.

Neither I'm sure of what you are trying to do but I the first thing I have done is to align a ship to gravity so here are a few things that helped me:

You can get a block direction with block.WorldMatrix, if I recall correctly, here is a good explanation: https://forum.keenswh.com/threads/t...transformations-with-world-matricies.7399827/, so you can take block.WorldMatrix.Up of the thrusters.

For the gravity there are some blocks that can give you the total gravity vector, with GetTotalGravity() (other options are GetNaturalGravity and GetArtificialGravity I think), I'm guessing that Remote Control is one of those.

For aligning those vectors I have used a Gyro, setting Pitch, Roll and Yaw (each one of those changes one coordinate of the orientation, you might have to try to guess which one).

Last edited: Mar 4, 2019
3. ### ASmilingNinjaTrainee Engineer

Messages:
4
I looked into this a bit and couldn't find any methods for the cockpit blocks that gives the information you need. I was hoping to build a ship with thrusters that would rotate to point down as the pitch of the ship changed.

I will have to look at gyros to see what they have to offer.

Edit:
Gyros have a Property for pitch. It is just a float value so if that value is relative to the gravity vector, it should be easy to use. If not, you might have to figure out the relation between gravity vector and the Pitch reported by a gyro. Unfortunately I can't look further into it at the moment.

Edit 2:
Unfortunately the pitch you get from the gyros looks to only be the current input from the user.

Last edited: Mar 9, 2019