- Home /
Vector3 and power
How does the vector 3 statement translate to a force? The following code launches a projectile and it does succumb to gravity. I would like to be specific about the mass, angle and force applied, and the let unity do the rest :). Am I on the right path? Thanks for any comments.
var myCounter = 0;
function FixedUpdate () { // Apply force for 15 somethings while ( myCounter < 15) { var power: Vector3 = Vector3(0,25000,25000); rigidbody.AddForce(power, ForceMode.Force); myCounter++; } }
Please consider reformatting your code by selecting it and pressing the button that looks like a bunch of 0's - you'll be more likely to get help.
Answer by spinaljack · May 01, 2010 at 09:28 AM
The length of the vector is what you want.
You can calculate the angle between the forward vector and your target vector with this
If you want to specify the direction of the vector and then apply a specific length first you find the normalised vector (unit length) and then simply multiply by the power you want
If you want to enter a specific angle you can set the rotation to be horizontal and then use the rotate function to tilt the angle up
Forward is the z-axis (x is right, y is up). Target Vector is the direction you want to end up in so if you're using smooth rotate the object will rotate towards the target vector over several frames. (although without context it's hard to know what you're talking about)