Hello, I have two questions regarding force and rotation? 1: Is there anyway to have force dependent on rotation (the object moves towards its relative forward direction, etc.) rather than vectors (my current script is this):
2: Is there any way to have an continually object rotate from -45 degrees to 45 degrees?
Its for a bowling game is that helps put the questions into context. thanks.
asked Nov 26 '10 at 06:37 AM
To add a force in the direction of the object's own forward direction, you can use AddForce and use transform.forward as the vector direction. This vector (along with .right and .up) has a length of 1, so you can multiply it by any value you like to give the total power of the force applied. For example:
To rotate an object using physics, you generally should use the rotational equivalent of AddForce, which is AddTorque. However, if you want to precisely rotate an object from -45 to 45 degrees, this might be better done without using the physics engine (since using physics forces tends to yield imprecise results).
I'm going to take a wild guess here and assume this is a power meter needle for a power gauge which goes from -45 to 45.
To implement this, I would have the power range go from 0-1 while you hold the fire button down, and then add the force when you release the button. The code might look something like this:
answered Nov 26 '10 at 07:09 AM