Ideas for firing thrusters based on camera position in 3d a enviroment
So I am building a 3d lander type game. I am still fairly new to Unity.
I have set up a camera to orbit around my craft based on mouse input. I have also set it so that if i push my W key, my craft starts to gain momentum in the direction my camera is facing. However, if I move my camera along my orbit circle so that I am looking the exact opposite direction, and I press my W key, my craft will start to slow down, and then gain momentum again in the direction I am currently facing.
Here is my problem, I have a cone shaped lander that has 4 thrusters that fire along the X and Z axis. I want to fire the particle system based on the direction my camera is facing, so that my side-to-side movement, and my back-and-forth movement correspond to the thruster(s) that are firing. Any suggestions?
Answer by HenryStrattonFW · Nov 06, 2015 at 03:40 PM
If i understand correctly what you want to do is Work out, based on the camera facing direction", which thrusters to fire to move in that direction.
If that's the case, then what I suggest is Dot Products. A dot product of two vectors gives you a value describing how similar those vectors are. For example two identical vectors in direction and magnitude, would produce a dot product of one. invert one of those vectors to point in the opposite direction, and the dot product becomes -1. Two vectors of the same size at 90 degrees would be 0, and so on.
Id suggest using a dot product between your cameras forward direction and the direction that each thruster is responsible for moving in. Then if the result is within a certain threshold, consider that thruster to be activated and trigger its effect accordingly.
You may want to play around with dot products to get a firm grip over what they do, and what results to expect, but that is the direction I would go If I've understood your question correctly.
Your answer
![](https://koobas.hobune.stream/wayback/20220612043605im_/https://answers.unity.com/themes/thub/images/avi.jpg)