- Home /
How to rotate rocket using thrusters
cyan cube shows direction I want rocket to rotate how to make code that selects thrusters that will move rocket in shown direction
This question makes little sense!
Do you want to Rotate the object, or Move it?
The thrusters will have no Impact on either!! They should simply be there for "Display Purposes". To actually move/rotate the object, add a collider + RIgidbody to it, and move + rotate it via code... You can just Google "Unity Scripting API - Rigidbody.Addfore/Rigidbody.velocity/Rigidbody.rotation".
Title says everything. Lmao I am sorry that you can't read!
Answer by DrJBN · Apr 23, 2021 at 07:38 PM
This is off the top of my head- Get the direction from the rocket to the cube. Then get the direction from the rocket center to each thruster. Normalize those thruster directions and get their Vector3.Dot product with the direction you want to travel. Activate the two thrusters that give negative dot-products and activate them in proportion to the absolute value of the dots. What I think I just said is find the two thrusters that are pointing away from the cube (those with negative dot products). Those dot products are the cosine's of the angles and should be between 1 and -1. The - values point away from the cube, so activating them pushes toward the cube. One that is at -1 is 180 degrees from the cube, and activating it will move directly toward the cube. If neither are directly away, then activate both in proportion to the dot's you get. You'll have to play with that last step a bit to get it how you want it, but it should get you started in the right direction (pun intended).
Your answer
Follow this Question
Related Questions
Throttle interpreted as nothing? 1 Answer
calculating the thrust duration to apply to a body to reach a certain height 2 Answers
How to make thruster rotation 0 Answers
Composite body physics 2 Answers
2D 360 degress platformer example needed 0 Answers