- Home /
Gun Scope Not Centered
I'm having the most annoying issue with my gun scope. When I Use it, It's not centered. Here is a picture of what happends:
I Understand I Have to have my sights lined up to the centre of the gun, But when I Do that, This is what happends:
My Gun is really low to the ground. This is my current Scope script:
var cameraObject : GameObject;
@HideInInspector
var targetXRotation : float;
@HideInInspector
var targetYRotation : float;
@HideInInspector
var targetXRotationV : float;
@HideInInspector
var targetYRotationV : float;
var rotateSpeed : float = 0.3;
var holdHeight : float = -0.5;
var holdSide : float = 0.5;
var racioHipHold : float = 1;
var hipToAimSpeed : float = 0.1;
@HideInInspector
var racioHipHoldV : float;
function Update ()
{
if (Input.GetButton("Fire2"))
racioHipHold = Mathf.SmoothDamp(racioHipHold, 0, racioHipHoldV, hipToAimSpeed);
if (Input.GetButton("Fire2") == false)
racioHipHold = Mathf.SmoothDamp(racioHipHold, 1, racioHipHoldV, hipToAimSpeed);
transform.position = cameraObject.transform.position + (Quaternion.Euler(0,targetYRotation,0) * Vector3(holdSide * racioHipHold, holdHeight * racioHipHold, 0));
targetXRotation = Mathf.SmoothDamp( targetXRotation, cameraObject.GetComponent(FPSMouseLook).xRotation, targetXRotationV, rotateSpeed);
targetYRotation = Mathf.SmoothDamp( targetYRotation, cameraObject.GetComponent(FPSMouseLook).yRotation, targetYRotationV, rotateSpeed);
transform.rotation = Quaternion.Euler(targetXRotation, targetYRotation, 0);
}
If you know how to fix this, Please leave a comment below! Thanks in Advance!
What form of scope is this? The COD type where you use the same camera and bring the gun up to it, while changing field of view?
I believe a possible way to fix this is to load the gun under a new game object... the center of its transform is off, by my guess, but im not sure if i'm fully understanding whats going on here.
Ahh, sorry. What do you mean? Anyway, what's going on is the gun scope isn't at centre of screen. (Picture 1) Apparently you need to line tge centre of gun up with the sights but then my gun on spawn is really low. (Picture 2)
Answer by Griffo · Aug 14, 2012 at 10:00 AM
take a look at this post ..
http://answers.unity3d.com/questions/300946/vector3lerp-move-weapon-up-to-players-face.html