I have been working on a script to throw a tomahawk/throwingknife (just like throwing a knife in real life), and the script works fine only when im facing one direction. If I change directions the tomahawk will still add force but it will be thrown behind the player instead of infront. Can you please help me. I have two Scripts attatched to this one for the spawning place of the tomahawk and one for when the tomahawk has been spawned and now adding force to it.
//SpawningPlace
var tomahawk : GameObject;
var tomahawkSpawn : GameObject;
var cameraObject : GameObject;
function Update ()
{
ThrowingTomahawk();
tomahawkSpawn.transform.position = cameraObject.transform.position;
tomahawkSpawn.transform.rotation = cameraObject.transform.rotation;
}
function ThrowingTomahawk ()
{
if(Input.GetButtonDown("Equipment"))
Instantiate(tomahawk, tomahawkSpawn.transform.position, tomahawkSpawn.transform.rotation);
}
//AddingForce
var throwingForce : float;
var spinningSpeed : float;
function Awake ()
{
rigidbody.AddForce(0, 0, throwingForce);
rigidbody.AddTorque(Vector3.right * spinningSpeed);
}