virtual Button for adding force to a rigidbody of a ball

hello

i want to make virtual button to add force to a rigidbody of a ball.

for example i want to make separate virtual buttons for add force to forward and left and … of ball rigidbody also i want use textures as virtual buttons.

Thank you

Two separate issues:

o What coordinate system do you want to use for the push? Vector3.right will push the ball “East” on the map. transform.right will push in a random direction (sine the ball is rolling, it’s “right” could be anywhere. Camera.main.transform.right will push it right based on the view angle. You can also figure out “using current speed as forward, right based on that.”

You can rig that up just using things like if(Input.getKeyDown("a")) { push } for testing.

o Where to you want the button? On the bottom of the screen? To the left and right of the ball? GUI.Button(...) works alright (you’ll read that’s it slows you down – but maybe 1/10th of a frame for each – all that matters is if you program runs fast enough. Try looking a Camera.main.WorldToScreenPoint(Input.MousePosition) if you want to position it near a 3D object (you can find this in all the Qs about displaying hit points of lifebars.) Look at GUIStyle for textures.

Experiment with putting buttons in the right spot – don’t have them do anything yet. Once you get both halves working (buttons + pushing) easy to combine them.

i’m working on mobile (android) i want virtual buttons like that exist in unity3d (Player Relative control) but i only want to add force to regidbody of a ball.

hello

how to make buttons (touch button) for add force to rigidbody of a ball ?(i don’t want to use GUI buttons.)

thank you