Question by
The-Evster · Jul 31, 2016 at 12:21 PM ·
transformscript.vector3aimdownsights
Problem with aiming Script(Only Some Code Works)
I need help figuring out what is wrong with a aiming script. When Fire2 is pressed the crosshair is lo longer viable and the debug message shows up in the console. However the transforms location does not change to the new Vector3 location(aimPos). Everything else works except for the transform moving to the aim location.
//ADS
public bool isAiming = false;
public Vector3 defaultAimPos = new Vector3(.2f, -.2f, .7f);
public Vector3 aimPos = new Vector3(0, -0.137f, 0.5f);
void ADSFunction()
{
CanvasGroup crosshairGroup = _CrossHair.GetComponent<CanvasGroup>();
//Setting the aim
if (Input.GetButton("Fire2") && _isRunning == false)
{
isAiming = true;
inaccuracy = 0;
this.transform.localPosition = aimPos;
crosshairGroup.alpha = 0f;
Debug.Log("You should be aiming");
}
else
{
isAiming = false;
this.transform.localPosition = defaultAimPos;
crosshairGroup.alpha = .5f;
}
}
Comment
Your answer
Follow this Question
Related Questions
Applying direction into transform position 0 Answers
Why doesn't my asteroid field perfectly move with me? 1 Answer
Why is the script not working anymore? 0 Answers
gameobject position lerp 0 Answers