Hello all, im new here. I ran a search though google as well though the forms and read up to page 5, but im not seeing my issue. When searching I seem to get many results looking for ways to track double taps / clicks and key inputs. My problem appears to be that when using Input.GetKey and I double tap, my input continues.
I currently have the following code for my top down camera controls and its a bit weird for this to have a double tap feature. Is there a way I can disable this? I am not using any double tap checks or anything,
I don’t see anything there tracking touches our mouse buttons going down. If there is a problem in your doubleclick code, I don’t think you posted it above.
Also: if you are attempting to detect clicks in FixedUpdate(), move that detection code to Update().
Thanks for the reply, before I dump the entire script in here (58 lines) I just want to make sure its fine rule wise, didnt see a “this channel rule list”.
As for the “Update()” its currently in “void Update()”
It’s not okay to dump entire scripts in here and say “HAAALLP!”
It is okay to dump an entire script in here and say “I am doing A and I expect it to behave like A but it is behaving like B and I think the problem might be here in line 57 because variable X is always zero no matter what I do and I don’t understand how that could be.”
Here is how to report your problem productively in the Unity3D forums:
Also, to help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.
Doing this should help you answer these types of questions:
is this code even running? which parts are running? how often does it run?
what are the values of the variables involved? Are they initialized?
Knowing this information will help you reason about the behavior you are seeing.
Thanks for the above, I believe im following most of those rules. As for the code, I dont think posting the entire code would help at all as I get no errors. Technically speaking, its working as intended, but I dont expect my camera to skirt off to X direction when you double tap x button.
Items not listed here in this script would be as follows
Variables
Zoom in and out
Clamps to keep the camera in scene
Lockout when you press “Escape”
What I believe is happening is similar to what I could describe in terms of other games would be “Double tap to dodge roll” or “Double tap to short dash”
I went to toss some Debug.Log’s into my code and like always, the error seems to have vanished leaving me even more confused. Ill update this later if the double tap function comes back.
And because I said it went away, it seems I found the variables on why i thought this was fixed. It seems to only happen when entering the key presses on my computer vs this wireless keyboard. So it appears this may be related to my laptop rather than unity as its not consistent. Ill submit a bug report.
Reading the first code you posted, if you slide the mouse to any side that makes the second half of those huge if statements true (you are using a logical OR), to me it seems that it would continue scrolling indefinitely no matter what else, unrelated to clicking or keypresses or anything. Is that what’s going on?
I tested the code with out the “or” to see if maybe you were onto something here, but that does not seem to be the case. With exactly as following the issue still exists
if (Input.GetKey("w"))
{
transform.Translate(Vector3.forward * panSpeed * Time.deltaTime, Space.World);
}
As for the “indefinite scrolling” if you hold the mouse while in the “side of the screen” I have that part solved with the following, so I dont think thats the cause either as this happens with out the above after or components.