aldian
July 28, 2012, 5:17pm
1
Hi im having problems with my gun aim script, first off i have no idea what the default names/buttons are for “fire2” as mine seem to be missing. Also My gun seems to float in the air for some reason
Code:
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.3;
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(MouseLook).xRotation, targetXRotationV, rotateSpeed);
targetYRotation = Mathf.SmoothDamp( targetYRotation, cameraObject.GetComponent(MouseLook).yRotation, targetYRotationV, rotateSpeed);
transform.rotation = Quaternion.Euler(targetXRotation, targetYRotation, 0);
}
thanks
i have watched the script and i know where it comes from, you forgeted this its stand at the bottom of the script:
aldian:
transform.rotation = Quaternion.Euler(targetXRotation, targetYRotation, 0);
transform.rotation = Quaternion.Euler(targetXRotation, targetYRotation, 1);
}
i hope it helps!