I am teaching myself unity 3d 4.3 so i can create 2D game.
As a practice i am writing scorched earth.
It is 2D and I rotate the gun barrel, around Z-axis. Lets say it is pointing to right, up 45 degree.
Now I created a bullet as child of the barrel.
I have code
GameObject newBullet = (GameObject)Instantiate(originalBullet, originalBullet.transform.position, originalBullet.transform.rotation);
newBullet.rigidbody2D.AddForce(new Vector2(1,1) * 250);
Original bullet is placed right in front of the barrel and i clone it.
I am having problem with AddForce. Vector2(1,1) is hardcoded to 45 world-degree, but how do I get the direction of the barrel in relation to the world?
Also, is there a good example i can look at it for writing tank shooting game?
Thanks