- Home /
Screen moves on clicking the button
I am using following code to throw the ball. When the player clicks on "Hit" button the screen also moves to the left side.
I need solutions for two different situations if any can help:
Either the screen does not move on clicking the GUI Button.
Either I remove the button and click to fire using: if(Input.GetButtonDown("Fire1")) instead of Gui.Button in this case also when the screen is touched to "Fire" or even "move the screen" to the left or right, the ball is thrown and the screen also moves to the left/right side.
Regards,
Zia Khatri
function OnGUI() { if(GUI.Button(Rect(125, Screen.height-125 , 250, 125), "Hit") ) { if(actionStatus == false){ if(slabstatus1.Balls_count<3){ var ball: GameObject = Instantiate(ballPrefab, transform.position, Quaternion.identity) as GameObject; ball.rigidbody.AddForce(transform.forward * 900); } actionStatus = true; } } }
by the Screen "$$anonymous$$oving", do you mean the camera in the scene?
unless the camera is inside a moving object, I do not see how this script is affecting the camera's transform...
Answer by ziakhatri · Aug 02, 2011 at 09:34 PM
Yes, I mean the camera moves on Gui Button click.
The Ball is instantiated on fire or screen is touched/clicked and the ball script is placed on the camera (First personal).