Godot Version
4.2
Question
I want to ease transition a sin frequency from 50.0 to 0.75
public override void _Process(double delta)
{
time += (float)delta;
MoveX(delta);
Shake();
}
void Shake(){
if(frequencyY > 1)
frequencyY -= 1;
}
void OnClickButton(){
frequencyY = 500;
//I tried using tween here as well
}
public void MoveX(double delta){
Godot.Vector2 pos = new(0,0);
var s = Mathf.Sin(time * frequencyY + index) * amplitudeY + offsetY;
var c = Mathf.Cos(time * frequencyX + index) * amplitudeX + offsetX;
pos.Y = s;
pos.X = c;
node2D.Position = pos;
}
This makes a canvas item move from left to right and up and down using sin and cos. I attached a button on it to increase the frequency to 500. Then the process reduces the frequency over time. Right now the canvas item shakes at the button press; however, the object slows down randomly. I just want it to shake really fast then slow down. I have tried using tween, a trauma slider, and I tried taking out *time and replacing it with a constant rate. Anyone got any clue to make this work?