Move sphere on gui button hold

Hi guys,

I currently have a sphere i can move around using the arrow keys and force in the fixedupdate.

I just created some canvas buttons because i wanna use those to move my sphere around. I have seen some people use the OnGUI in which they use transform.

My question is, is this smart? Update and fixedupdate run on the FPS, OnGUI doesn’t. This would mean i would move my sphere “outside of the fps context”.

Any help is welcome!

PS: i wanna move the sphere using GUI buttons because I’m creating an android game.

Using OnGUI for anything else other than GUI stuff is not a good idea.

See my answer here about Update vs. FixedUpdate. You could probably substitute OnGUI for Update, but it would be wise to add an extra separation between functions and pass OnGUI inputs to Update then onto FixedUpdate.

Also, to clarify; FixedUpdate is NOT FPS dependent, it’s “fixed” FPS for physics in Time project settings (by default 0.02 ms or 50 fps).

@conman79 thx for answering

So talking about transfoem should happen in update, talken abou physics like force should happen in fixedupdate?

Well i clearly need an example how i could move my sphere with force using the canvas buttons because i srill have no clue :(.