Question by
JackTheKreator · May 20, 2016 at 05:31 PM ·
prefabfpsscaleaimprimitives
Scaling Prefabs correctly?
I'm making an fps, and the guns are made of primitives. Sometimes a make a gun too big or too small, and I just scale the prefab to make it right. However, this seems to have butchered my aiming system:
void HandleAiming(){
if (AllowScope && CurrentScope != null && Aiming) {
transform.parent.gameObject.GetComponent<Camera> ().fieldOfView = Mathf.Lerp (transform.parent.gameObject.GetComponent<Camera> ().fieldOfView, CurrentScope.AimFOV, 0.2f);
GameObject.FindGameObjectWithTag ("WeaponCam").GetComponent<Camera> ().fieldOfView = Mathf.Lerp (GameObject.FindGameObjectWithTag ("WeaponCam").GetComponent<Camera> ().fieldOfView, CurrentScope.AimFOV, 0.2f);
Vector3 ScopeCenter = CurrentScope.GetComponent<BasicScope> ().ScopeCenter;
Vector3 ScopeBaseCoords = ScopeCenter + CurrentScope.transform.localPosition;
Vector3 Destination = GunCamera.transform.localPosition;
Destination.z += 0.4f;
gameObject.transform.localPosition = Vector3.Lerp (gameObject.transform.localPosition, Destination - ScopeBaseCoords, 0.25f);
} else if (AllowScope && !Aiming) {
gameObject.transform.localPosition = Vector3.Lerp (gameObject.transform.localPosition, HipPosition, 0.4f);
transform.parent.gameObject.GetComponent<Camera> ().fieldOfView = Mathf.Lerp (transform.parent.gameObject.GetComponent<Camera> ().fieldOfView, 60f, 0.2f);
GameObject.FindGameObjectWithTag ("WeaponCam").GetComponent<Camera> ().fieldOfView = Mathf.Lerp (GameObject.FindGameObjectWithTag ("WeaponCam").GetComponent<Camera> ().fieldOfView, 60f, 0.2f);
}
}
making the scope's Y aligned messed up. Could someone help me on this? The scopes' pivot points is their rear base, btw.
Comment
Your answer
Follow this Question
Related Questions
function works script-wise; doesn't work visually(only in game) 0 Answers
Script creating 2 prefabs instead of 1 0 Answers
How do I fire a laser at the player's Y level. 0 Answers
Problem with instantiate and destroy multiple objects 0 Answers
Player Prefab scale automatically goes to 1 x 1 x 1 whereas I have set it to 0.48 x 0.48 x 0.48 1 Answer