Quantcast
Channel: Questions in topic: "unresponsive"
Viewing all articles
Browse latest Browse all 108

Help with unresponsive function / if statement

$
0
0
Hey everyone, I'm attempting to make my character pick up an object. The problem I think I'm having is that the function the code to pickup an item is in (onTriggerStay) seems to run half as often as the update function, and therefore, when the player presses the "Interact" button, approximately half the time, the function isn't running, and nothing is listening for the interact button. Just to clarify, the code works, but only registers half of my button presses. function OnTriggerStay(other: Collider) { if(Input.GetButtonUp("Interact") && other.gameObject.CompareTag("Pickup")) { print("TriggerTest = "+triggerTest++); } } Now, I have tried placing this code before and after the functionUpdate, I've tried using GetButtonDown instead of up, I've tried the control key on my keyboard, and an Xbox controller (Two different input methods). The reason I think the function is only running half the time, is because if I comment out /*Input.GetButtonUp("Interact") && */ in the if statement, and add a similar counter into the function update, in the log, the function update tends to count up twice for every one time the OnTriggerStay updates . Does anyone know why this would be happening, or what I could do to further troubleshoot my issue? I made a work around for this yesterday, but even after sleeping on it, I'm still not happy with the result I have achieved (and can see potential complications arising as the project gets more complex).

Viewing all articles
Browse latest Browse all 108

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>