Reversed Rotation Problem
Hello everyone, I've been working on a 2D platformer game for a bit. But I've had a problem with the rotation of my player character's gun and the bullets being fired from it, which I've been stuck on for quite a while now. The idea is to rotate the gun and fire projectiles towards the mouse location. This more or less works fine when facing the right (the default scale).
However, when I face my character left, the vertical rotation is reversed, and I'm unable to find a decent solution to this.
The character and weapon are build in the hierachy as follows:
Player
- gunArm
- - Weapon
- - - FirePoint
- - - WeaponModel
The flipping is done by flipping both the player and the gunArms x-scale:
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
Vector3 armScale = gunArm.transform.localScale;
armScale.x *= -1;
gunArm.transform.localScale = armScale;
The projectile fired takes the same rotation as a firePoint object attatched to my gun:
for (int i = 0; i < firePoints.Length; i++) {
nextShotTime = Time.time + fireRate;
Projectile newProjectile = Instantiate (projectile, firePoints[i].position, firePoints[i].rotation) as Projectile;
}
During the testing I did find out that the projectile does indeed take the same rotation as my gunArm in the inspector, however the actual rotation is reversed. I've tried a whole lot, but always end up with this, or worse. Any help would be appreciated. In fact, any advice concerning rotation, Quaternions and all that is appreciated; these are a stumbling block everytime I encounter them.
Answer by Epicepicness · Aug 26, 2016 at 11:02 PM
Bump, still having trouble with this; would appreciate an awnser.
Your answer
![](https://koobas.hobune.stream/wayback/20220612091244im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
scalling with scripts 0 Answers
Spawn Different GameObject depending on Scale.,Spawning different Gameobject depending on scale. 0 Answers
Gun shoot problem? 1 Answer
Rotating object on z axis only when following mouse movements. 0 Answers
[Help] Objects rotate wrong when passing from 0 to 360 0 Answers