- Home /
Question by
seanmor96 · Apr 14, 2020 at 02:56 PM ·
rotatinglocalposition
Flipping the position of the gun when rotating player
So I have a roguelike player that can look in 4 directions and I have the gun flippiing when it hits 90 degrees and vice versa, but I want the gun to flip to the other side of the player as if it is going from his left hand to right hand. I tried using localPosition but it does seems to create 2 different players and guns and glitch out. Here is my code below that I have tried using. Any help would be appreciated!
//Flip weapon after certain angle
Vector3 aimLocalScale = Vector3.one;
Vector3 aimPositionScale = Vector3.one;
if (angle >= 90 || angle < -90)
{
aimLocalScale.y = -1f;
aimPositionScale.x = -1f;
}
else
{
aimLocalScale.y = +1f;
aimPositionScale.x = +1f;
}
aimTransform.localScale = aimLocalScale;
aimTransform.localPosition = aimPositionScale;
Comment
Your answer
Follow this Question
Related Questions
Add posititons relative to transform 2 Answers
Friction issue with rotating sphere 1 Answer
Changing Z-Axis of camera 1 Answer
Keyboard rotating - left is stopping object 1 Answer
Rotating Wrong 1 Answer