Hello!
I'm a beginner and i got stuck on my project trying to smooth the movement of my character using the lerp function. I read the documentation again and made a new simple project with one simple objective : create a circle following the mouse using smoothed motion (exactly like in the doc ; https://docs.godotengine.org/en/stable/tutorials/math/interpolation.html).
The problem is : the circle seems ancred to the origin of its parent node and i do not understand why.
Here is a gif to illustrate my problem:
And here is the code (i'm using C#).
`
using Godot;
using System;
public partial class Balle : CharacterBody2D
{
[Export]
public float speed = 4.0f;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _PhysicsProcess(double delta)
{
Godot.Vector2 mousepos = GetLocalMousePosition();
Position = Position.Lerp(mousepos, (float)delta * speed);
}
public override void _Draw()
{
Color ballColor = new Color(0.941176f, 0.972549f, 1, 1);
DrawCircle(Position, 100f, ballColor );
}
}
`
I feel like the line " Position = Position.Lerp(mousepos, (float)delta * speed); ", should update the position of the node during its movement but apparently not.
Can someone please help me? Thank you!