#Mouse clicks not registering

1 messages · Page 1 of 1 (latest)

distant phoenix
#

Where did you place that method call?

crisp aspen
#

are you sure its not working? i think whats happening is, clicked becomes true for a single frame (when the button is pressed down) and then gets set to false the frame right after

distant phoenix
#

Oh, I see. You already seem to have gotten the advice to not get input in FixedUpdate.
What you fail to consider here though, is that you are still syncing the input state every frame - which essentially results in the same as checking input in FixedUpdate.

#

The (general) solution is (or would be) to only set clicked to true in Update, and then reset it in FixedUpdate.

serene shadow
#

I disagree

#

The whole FixedUpdate loop here is completely pointless

#

The only thing remotely physics related here is the call to AddForce, and that's not even a continuous thing it's a one-shot (especially considering you're just doing it once, if mouse is pressed)

distant phoenix
#

Seems like a separate issue, but yes.

serene shadow
#

You really don't need FixedUpdate here at all tho

crisp aspen
#

do take into account what yasa said though
he is right

serene shadow
#

AddForce isn't continuous

#

FixedUpdate is for continuous physics operations

#

You're just simply applying a force if and only if the mouse is pressed, and for a single frame only

#

It's irrelevant what you use, it's one-shot

#

You could AddForce in Start, it doesn't matter. It's not a continuos thing

distant phoenix
serene shadow
#

It can be but here it's not

#

Also they are using Impulse WeSmart

distant phoenix