Turning a Character2D into a static/frozen state?
Asked Answered
R

3

0

Is there a good way to set a Character2D into something that's like "freeze" mode in RigidBody2D?

I want NPCs to be able to "freeze" in place and be unmovable, while still performing scripted actions like shooting. RigidBody Items fall on them and move them around in undesirable ways, like launching them into the sky or pushing them into the ground, but I still want those RigidBody to not pass through them, just like a StaticBody2D.

In my case it isn't really possible to change the node type at runtime, since the script is inherited from Character2D.

Rubenrubens answered 14/3, 2023 at 18:29 Comment(0)
S
0

While you can't change the node type itself, you could change the node parent or child, if you create a new node and have the kinematic body a child of that and then a separate static you could switch between the two using a script.

Sherrell answered 14/3, 2023 at 20:15 Comment(0)
R
0

Sherrell

That's true but would require extensive rewriting, as I based all game characters off of Character2D.

I probably should have gone with a more component-style approach so I could have different physics for the characters

Rubenrubens answered 14/3, 2023 at 22:11 Comment(0)
R
0

Sherrell

Good news:

Turns out just by not calling move_and_slide/etc, the Character2D will become Static!

Rubenrubens answered 15/3, 2023 at 0:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.