Two miscellaneous questions; odd variable declaration and abstracting movement from framerate?

Hey everyone,

I’ve run into two things recently that I’d like some clarification on. Let’s get the easier one out of the way first.

So I got some help on a script recently and in their script, they had a variable declaration that I hadn’t seen before:

float rotationAmount = 0, rotation;

Now, in the inspector, this popped up two variables, one rotationAmount and one rotation. Both were set to a value of 0. What’s going on here? Is this the same thing as:

float rotationAmount = 0;
float rotation = 0;

If so, can you instead do:

float rotationAmount, rotation = 0;

Ok, second question…might be a little more involved.

I’ve seen a lot of chatter about locking physics to framerate. I definitely get how that’s bad…so the idea is then to abstract the physics and movement and such from the framerate. So in order to achieve this, do you use physics based movement like AddForce(); as opposed to Translate();? Or is it enough to multiply your movement speed by Time.deltaTime? And this goes for every movement too. Meaning if you have animations moving for your UI, gameObjects moving around, etc. Or is it more complicated than that?

Thanks!

All varibles can be declared that way, and it is exactly the same as do a variable per line and you can just declare or you can give them defualt values as well. Just keep in mind if you use attribute on it like [SerializeField] [Range()] or anythign similar it will apply to all vars listed.

Part 2 yes when it comes to movement generally scalling it by Time.deltaTime is enough to make it independent from the framerate and work in seconds. Also there is a Time.fixedDeltaTime as well if you need to use it in a FixedUpdate. Just never used Time.deltaTime in a FixedUpdate.

Cool! Thanks! And yeah, I noticed when trying to do [Header(“blahblah”)] put blahblah at the top of every variable instead of the group of them.

yeah like i said if you added a attribute to a list of variables like that it will apply to each one