x


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:

  1. Either the screen does not move on clicking the GUI Button.
  2. 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; } } }

more ▼

asked Aug 02 '11 at 07:25 PM

ziakhatri gravatar image

ziakhatri
1 3 3 3

by the Screen "Moving", do you mean the camera in the scene?

Aug 02 '11 at 09:09 PM adeo8

unless the camera is inside a moving object, I do not see how this script is affecting the camera's transform...

Aug 02 '11 at 09:41 PM adeo8
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Yes, I mean the camera moves on Gui Button click.

more ▼

answered Aug 02 '11 at 09:34 PM

ziakhatri gravatar image

ziakhatri
1 3 3 3

The Ball is instantiated on fire or screen is touched/clicked and the ball script is placed on the camera (First personal).

Aug 02 '11 at 09:54 PM ziakhatri

Any here to reply?

Aug 03 '11 at 12:06 PM ziakhatri
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2498
x583
x488
x69
x30

asked: Aug 02 '11 at 07:25 PM

Seen: 900 times

Last Updated: Aug 03 '11 at 12:06 PM