- Home /
Mouse Input for RayCast - Update or FixedUpdate
Should the check for Mouse Inputs that are going to start a RayCast be in Update or FixedUpdate.
I ask as RayCasts are Physics and Physics should be done in FixedUpdate
but the checks for Input are typically done in Update
.
Which is correct in this scenario and why?.
Thanks.
Answer by Epsilon_Delta · Jun 25, 2019 at 05:09 PM
You can and imho should do the Raycasts for input check in the Update() as it is called every frame. Otherwise you could miss some clicks. It is true that you should apply force and do some other physics features in FixedUpdate(), but that mainly applies for things you want to do over several FixedUpdate() calls due to relatively stable deltatimes between individual calls, so that your physics is more deterministic. But when e.g. you want to apply explosion force only once, you can do it in Update() as well as in FixedUpdate().
Thanks, That's what I thought and set it up as but wanted a little confirmation.