#AddForce stops working when game is fullscreen?

1 messages · Page 1 of 1 (latest)

fervent heath
#

I'm using AddForce and it works in the editor but stops working when I expand the editor's game view to be fullscreen, for some reason. 🥴
I'm using it in Update, could be related (I thought it was fine to use it in Update though)

wet path
#

it's ok to use in Update if it's with Impulse or VelocityChange force modes (aka for instantaneous forces)

#

for continuous forces it'll be inaccurate/inconsistent

#

nothing about making it fullscreen would make it just, break, though.

#

have you tried debugging around that area?

fervent heath
wet path
#

make sure you've refocused on the gameview, perhaps? is everything else frozen?

fervent heath
# wet path make sure you've refocused on the gameview, perhaps? is everything else frozen?

What i'm doing is dragging the game view out into a separate window and then clicking that button at the top right that expands it to fill my entire screen (they removed the editor fullscreen feature at some point so this is what I do instead) and then I click on the game to focus it and then I can play and everything works in my game except this for some reason

wet path
#

they removed the editor fullscreen feature at some point
huh? that doesn't sound right. double-clicking the tab header doesn't do anything?

fervent heath
wet path
#

ah, so it's like, real fullscreen that's the issue.

#

do you have anything in console? have you debugged the code to see if it's running?

fervent heath
#

so "stops working" was incorrect, it just diminshes it somehow

#

wait sometimes it gets diminished way more. it seems to be different every time i play and go into fullscreen

#

there aren't any errors or warnings in the console

wet path
#

are you using Time.deltaTime

fervent heath
wet path
#

could you show the offending code

#

!code

glossy muralBOT
fervent heath
#
void Update()
    {
        if (jump.IsPressed())
        {
            rigidbody.AddForce(Vector3.up * jumpforce, ForceMode.VelocityChange);
        }
    }
fervent heath
# wet path !code

wait, i just realized that if I close the scene view, then i can put the game view into fullscreen without any problems

#

the scene view being open in the background is somehow breaking things?

wet path
#

huh that's weird

#

yeah i'm pretty lost on that. i didn't even know you could pull the window out and fullscreen it tbh

fervent heath
#

this is probably why putting it into fullscreen your way works, because it doesn't leave the scene view behind it

warm gazelle
# fervent heath ```cs void Update() { if (jump.IsPressed()) { ri...

IsPressed is true for as long as the button is pressed, and not just for the first frame it is pressed, right? Then this is a frame rate dependent velocity change.
The scene view can be quite performance heavy (even more so when a GameObject is currently selected, for some reason), so it could really just be this. Especially since you said you can actually see a change, just much less, and it's inconsistent. If you have much fewer frames when the scene view is open, that would make sense.

wet path
#

oh damn i didn't catch that, that sounds right

fervent heath
wet path
warm gazelle
wet path
#

you generally should use continuous forcemodes when you want continuous force, and you should not use continuous forcemodes in Update

fervent heath
rustic stream
rustic stream
#

Having it in Update makes your game framerate dependent (hence the full screen issues)

fervent heath
# rustic stream You can do exactly this in FixedUpdate

taking input in fixedupdate might cause it to be a bit unresponsive sometimes though i believe? i could do the bool method, however it's recommended to use an event based approach with the new input system instead, right? could i use that here or is this one of the things that can't be done that way?

rustic stream
#

IsPressed() is fine in FixedUpdate

#

It's only an issue if you're using WasPressedThisFrame or similar

rustic stream
fervent heath
rustic stream
#

Performance isn't a concern for this in any case