How to change the parameter of an object through a script? (Using C#)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Animaliss

I have a CharacterBody2D object in my scene.
I need to make it unfold.
I found out that changing the Scale by x will help with this …
But I can’t figure out how to do it through the script.

My current attempts look like this:

[Export] public CharacterBody2D playerCat;
playerCat.Set("parameters/Transform/scale", new Vector2(-1, 1));


playerCat.Set("parameters/Transform/scale/x", -1);

(This is written in _PhysicsProcess, besides [Export])

Both options do not give errors, but Scale absolutely does not want to change(
I’m new to Godot, please explain to me how to correctly access object parameters.
PS: I read this comment… It’s interesting, but I can’t change the variables at all, so that later I can experiment what exactly would be better to change.

:bust_in_silhouette: Reply From: Game_gulf

try this

self.scale.x *= 0.01


playerCat.scale.x *=0.01

How is this supposed to help?
After all, I need not to reduce the character, but to mirror it.
But thanks for the hint about the print.
For me (in C#) it looks like this: GD.Print(player.Scale);
And for some reason player.Set does not want to work in any way (
(And the print confirms this too)

Animaliss | 2023-05-06 00:30

:bust_in_silhouette: Reply From: Animaliss

I found the solution to my question and immediately the Godot logical jamb.
First, I moved the playerCat’s script to the stage, where there is access to the AnimatedSprite2D… which has such a convenient and logical Flip item.
As a result, this code deploys the character:

if (velocity.X > 0)
	playerCatSprite.FlipH = false;
else if (velocity.X < 0)
	playerCatSprite.FlipH = true;

But at first I thought for a long time that it didn’t work either, and why?
Because when you click on “Copy property path”, flip_h is copied, not FlipH at all, as it is written above in the code.
(And “playerCatSprite.flip_h = true” of course didn’t work)
In general, Godot suggests the path to the properties in the GDScript language, even if you write in C #…

The question why the following code doesn’t work remains open…

player.Set("Parameters/Transform/Scale", new Vector2(-1, 1));

(I’ll be back here when I find the answer to my question)