Godot 4.1.3, Dodge the Creeps 2D mobs stop moving
Asked Answered
A

19

0

Hey all, just built the DtC2D game. I was playing around with some parameters and decided to lower the mob velocity range:

`# Choose the velocity for the mob.
var velocity = Vector2(randf_range(50.0, 60.0), 0.0)
mob.linear_velocity = velocity.rotated(direction)`

(I believe tutorial had 150.0, 250.0 as the range). Anyway, slower mobs seem to spawn in an move as intended, but as they move across the screen, slow down gradually until become immobile...they are still animated, just not moving with any velocity. I'm not sure if mobs that are traveling faster are doing this too, but just happen to move through the screen and despawn before it becomes noticeable. Any ideas why this is happening?

Acriflavine answered 1/12, 2023 at 19:28 Comment(0)
I
0

Acriflavine Seems to work fine for me from what I can tell. Can you show a video of what is happening or some other code that might be related?

Isodimorphism answered 2/12, 2023 at 10:50 Comment(0)
I
0

Acriflavine but as they move across the screen, slow down gradually until become immobile...

Isodimorphism Seems to work fine for me from what I can tell.

I checked. I confirm the problem. In G4.2, it's the same situation.

Iridis answered 2/12, 2023 at 12:33 Comment(0)
I
0

Iridis Really? I did not notice but maybe it took too long to slow down.

Isodimorphism answered 2/12, 2023 at 12:39 Comment(0)
I
0

Uh-huh. 😃 I've set the same parameters as TS.

Iridis answered 2/12, 2023 at 12:52 Comment(0)
I
0

Iridis How long did it take for the effect to become noticeable?

Isodimorphism answered 2/12, 2023 at 13:33 Comment(0)
I
0

Isodimorphism Immediately. The very first mobs start slowing down.

Iridis answered 2/12, 2023 at 14:56 Comment(0)
I
0

Iridis Ah I see. Because that wasn't happening for me at all.

Isodimorphism answered 2/12, 2023 at 15:36 Comment(0)
V
0

I just tried making that change in a Godot 3 version of Dodge the Creeps. In that case, the creeps (RigidBody2D's) slow down because they start filling up the screen and colliding with each other.

I ran into a similar problem in a game I'm developing. To solve it, I placed a limit on the number of enemies that can exist at a time, and also apply random forces to keep them moving.

Verbose answered 2/12, 2023 at 16:10 Comment(0)
I
0

Verbose In that case, the creeps (RigidBody2D's) slow down because they start filling up the screen and colliding with each other.

Well, are they supposed to affect each other? 😕

Iridis answered 2/12, 2023 at 17:20 Comment(0)
V
0

They're RigidBody2D's. You can give them an initial velocity. After that, their behavior is controlled by physics.

Verbose answered 2/12, 2023 at 17:25 Comment(0)
I
0

Verbose After that, their behavior is controlled by the physics engine.

They have disabled physical interaction with each other in the layers:

In addition, under the CollisionObject2D section just beneath the RigidBody2D section, expand the Collision group and uncheck the 1 inside the Mask property. This will ensure the mobs do not collide with each other.

What's slowing them down?

Iridis answered 2/12, 2023 at 17:32 Comment(0)
V
0

I must have missed that instruction. If I uncheck the 1 inside the Mask property, then the creeps don't collide, but they do slow down.

So I can confirm the problem, and apparently it's not new to Godot 4.

Verbose answered 2/12, 2023 at 17:45 Comment(0)
V
0

If I change the property RigidBody2D.linear_damp from -1 to 0, then the slowdown does not occur. That's in Godot 3.5.3.

Verbose answered 2/12, 2023 at 18:16 Comment(0)
A
0

Thanks for the confirmation everyone.

Verbose If I change the property RigidBody2D.linear_damp from -1 to 0, then the slowdown does not occur. That's in Godot 3.5.3.

Interesting...but it looks like it was already set to 0 in the version of the tutorial I built from.

Acriflavine answered 2/12, 2023 at 18:56 Comment(0)
V
0

Is linear_damp_mode also 0? If so, try changing it to 1.

Verbose answered 2/12, 2023 at 19:3 Comment(0)
A
0

I played around with RigidBody2D.linear_damp. When I set it to -1, the speed gets "negatively damped" (the mobs noticably accelerate as they cross the screen). Setting it to roughly -0.1 seemed to counterbalance the deceleration that I was noticing from before, allowing the mobs to maintain approximately a constant speed before they exit and despawn.

So, that'll work around the issue temporarily, but I assume having any slowdown when linear damp is set to 0 wasn't the intended behavior.

Acriflavine answered 2/12, 2023 at 19:27 Comment(0)
V
0

linear_damp_mode is also a factor.

Verbose answered 2/12, 2023 at 19:35 Comment(0)
A
0

Verbose Is linear_damp_mode also 0? If so, try changing it to 1.

Thanks! damp_mode was set to 0 (combine)...setting it to 1 (replace) seemed to fix it. Mobs now seem to maintain their initial speed when damp is set to 0.

Huh, I wonder if there is a reason for the discrepancy in behavior between modes when damping is set to 0 anyway.

Acriflavine answered 2/12, 2023 at 19:40 Comment(0)
I
0

Acriflavine damp_mode was set to 0 (combine)...setting it to 1 (replace) seemed to fix it.

It might be reasonable to add this to the documentation.

Iridis answered 2/12, 2023 at 20:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.