Answers for "Switch force from horizontal to vertical"
http://answers.unity.com/questions/675978/switch-force-from-horizontal-to-vertical.html
The latest answers for the question "Switch force from horizontal to vertical"Answer by robertbu
http://answers.unity.com/answers/675986/view.html
One issue is that Mathf.Cos() and Mathf.Sin() takes radians for input, not degrees, so this line should be:
vectorThrust = new Vector3 (thrust * Mathf.Cos(thrustDir * Mathf.Deg2Rad), thrust * Mathf.Sin(thrustDir * Mathf * Deg2Rad), 0);
Note as an alternative, you could do use an Quaternion.AngleAxis() for the rotation. Something like:
vectorThrust = Quaternion.AngleAxis(thrustDir, Vector3.forward) * Vector3.right;
Based on your code above, I'm assuming this is a 2D game. I don't know your specific setup. You may want to use another base vector (Vector3.left, Vector3.down), and you may need Vector3.back instead of Vector3.forward. But the concept is the same. You are just picking some base vector and rotating it around the word 'z' axis by angle.Fri, 28 Mar 2014 23:38:57 GMTrobertbu