List of gameObjects unresponsive to fast button presses
Hi Y'all,
I hope I can explain this issue clearly...here goes :)
I have 4 rows of 10 objects (hoops). Some rows move from left to right on the X axis and others vice versa.The hoops contained within each row are stored in their own individual list.
What I need is for the hoops to move by -80 units upon pressing the jump(space) button. I am using this code (inside Update) in order to achieve this :-
//MOVE HOOPS ON Z AXIS WHEN JUMP IS PRESSED
if (Input.GetButtonDown("Jump") && BallCollision.isGrounded == true)
{
foreach (GameObject hoop in hoopList)
{
if (hoop.transform.position.z > -85)
{
//MOVE GAMEOBJECT SO RESPAWN HOOPS APPEAR ON CORRECT ZPOS
hoopsinZmove = true;
//MOVE ROW (LIST OF HOOPS) TO CORRECT ZPOS
iTween.MoveBy(gameObject, iTween.Hash("z", -80, "time", 0.4f, "easetype", iTween.EaseType.linear));
//STOP HOOPS X MOVEMENT PRIOR TO APPLYING ITWEEN Z MOVEMENT
Rigidbody thisRb = hoop.GetComponent<Rigidbody>();
Vector3 stopxMove = new Vector3(0, 0, 0);
thisRb.velocity = stopxMove;
//MOVE EACH HOOP IN ROW TO CORRECT ZPOS
iTween.MoveBy(hoop, iTween.Hash("z", -80, "time", 0.4f,
"easetype", iTween.EaseType.linear, "oncomplete", "HoopMoveOver"));
}
}
As you can see, i'm using an itween to move the hoops and to be honest this code works fine as long as there is a gap of about at least half a second between button presses.
The problem arises when I begin pressing more quickly. Most of the rows of hoops move on the Z axis as intended however one of them (different row each time) usually doesn't respond.
If anyone can shed any light on this then would be extremely grateful.
Thanks in advance :)
Your answer

Follow this Question
Related Questions
Make character follow cursor movement and detect collision 0 Answers
How can I animate my 3D object without affecting the physics? 0 Answers
Setting positions of points on Line renderer to mouse position does not work 1 Answer
Physics-related touch input (Continuous) 0 Answers
How to handle FixedUpdate() and Input 0 Answers