I’ve been fighting this a few days now. I’ve been playing with a few basic primitives to get a top down view working, as well some some basic form of shooting. However when I rotate the object the instantiated bullets fires off in two directions seemingly on the opposite axis from what that character primitive is facing. Here’s what I have atm in the script which isn’t much. I’m using the x,y axis and have the Z poking me in the face. The instantiation also seems to stay in the middle of the camera view instead of spawning where the primitive has been moved to. Any thoughts or at least what I’m doing wrong would be appreciated.
function Update () {
if(Input.GetKey(KeyCode.Space))
fire();
if (Input.GetKey(KeyCode.RightArrow))
//turret.transform.rotation.z += 0.01 * moveSpeed * 100;
turret.Rotate(Vector3(turret.position.x,turret.position.y,100) * Time.deltaTime);
print(turret.rotation);
if (Input.GetKey(KeyCode.LeftArrow))
//turret.transform.rotation.z -= 0.01 * moveSpeed * 100;
turret.Rotate(Vector3(0,0,-100) * Time.deltaTime);
print(turret.rotation);
}
function fire() {
var clone = Instantiate(bullet, turret.transform.right , turret.transform.rotation);
bullet.rigidbody.AddForce(transform.forward * speed);
}