When does constant_angular_velocity take effect?

Godot Version

v4.5.1.stable.mono.official [f62fdbde1]

Question

I am trying to experiment with a game where “atoms” bounce around inside containers. The atoms are to be emitted by an emitter on a timer basis and I wanted to make the emitter spin slowly, so that the atoms don’t all come out in the same direction.

I’ve tried making the emitter an AnimatableBody2D (based off some quick reading of the class descriptions) or a StaticBody2D and neither of them seems to take any notice of constant_angular_velocity. What I need is what I think is usually called “kinematic” behaviour, e.g. where the object is moved around by an external factor (in this case zero linear and constant angular velocity) and has a collision effect on fully physically simulated objects, but is not itself pushed around by them…

I must be missing something. I did see one YouTube tutorial in which he made a call to something like StaticBody2D.SetUseCustomIntegrator(false) which may be relevant but its not in the UI and it seems odd to have to go to code to turn on what I’d expect to be the default behaviour (don’t get me wrong, I am going to write lots of code for this, but at the moment I am just attempting to understand some detail of the physics system and this doesn’t seem like a thing I should need code for as yet?) And, anyway, I can’t find that in my current Godot version, so that may be obsolete (the guy was on v3, IIRC.)

Turning physics_interpolation_mode on or off doesn’t seem to change anything…

I’ll understand if this is not a situation where constant_angular_velocity takes effect, but it’s a member of StaticBody2D, so it must have an affect on that somehow, but so far I’ve not been able to find the case where it does anything…

Thanks,

Ian

It affects the impact on other bodies when they collide with it:

1 Like

Ah! Thanks, I did not actually find that pretty clear description when I searched… I probably followed all the search result except that one :frowning:

((The rest of this is me thinking through what to do based on your info, I think I overall get it now but please do correct me if I still have some misconceptions…))

That makes sense, except it leaves me wondering, if I want to make a kinematic body, do I need to be setting this (and the linear, if it applied) by hand to reflect how the object actually moved.

This in turn makes me realise I am still not sure what object type to use. I have been talking about kinematics as if that was the best way to do it, but maybe having a dynamic body with a pivot constraint so it only spins, and a way of calculating the torque so that it accelerates towards the desired spin is a better approach? (Or even just setting the rotation rate periodically, if it deviates? Not sure if the physics system(s) allow that…)

A-ha!

image

I think that is probably my answer:

  • move it in code (in _PhysicsProcess?)
  • set constant_angular_rotation to match that
  • we won’t detect collisions with dynamic bodies but
    • they will detect collision/overlap with us
    • but think they will try to separate from the static object via their standard physics processing? (I think I saw something like this described for kinematic character and it feels like, if we use static body for platforms, this would actually apply at this level…)