0 votes

So I am trying to make a script that disables a collision box so " Node " for the player and enables another one so that they could crouch or crawl. For a 2D game.

For example a godot Script

func physicsprocess(delta):
var col = getnode("CameraPosition/Area2D/CollisionShape2D")
col.set
disabled(true)
print(col.is_disabled())

For C# disabled does not exist, so the question is how do I disable the Node ?
Example code
2 Colliders : StandingCollison" Which is defaulted to true as in enabled and " CrouchCollision" which is disabled "False"

if (Input.IsActionPressed("uidown") && (onground == true)){
var node = GetNode("StandingCollison");

As far as I have searched I cannot figure this out, and throughout multiple forums that Godot has provided this has not been listed for C#.

The Colliders should Get disabled when A button is pressed and another one gets enabled, and when its pressed again it would then do the reverse, I want to know how to disable it..

Godot version Godot 3.2 Mono "C# support"
in Engine by (12 points)

1 Answer

0 votes

The CollisionShape2D class has a Disabled field. What are you missing is to specify the class in the GetNode() in this way:

var node = GetNode<CollisionShape2D>("StandingCollison");
node.Disabled = false;

If you just call to the GetNode without type, the node variable will have Node as type, and this type doesn't have the Disabled flag.

by (70 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.