Hi,
I've been searching for a good way to move my npc (it's a fish) to a position Vector3() with collisions detection.
First, I tried to use Tween :
public Vector3 Destination;
public float Time = 5.0f;
tween = GetNode<Tween>("Tween");
tween.InterpolateProperty(this,"translation",Translation,Destination,Time);
This solution was very accurate and easy to use but collision detection doesn't work: my fish pass through the ground, and IsOnWall() function return nothing.
The second solution was with MoveAndSlide():
public override void _PhysicsProcess(float delta)
{
Vector3 velocityAngle = Destination-Translation;
Vector3 movement = MoveAndSlide(velocityAngle.Normalized()*speed);
}
It was a good solution, I've got my collisions but I don't really know how to stop the movement precisely except with:
if(Translation.DistanceTo(Destination)<0.1f){
}
And lastely, I tried with LinearInterpolate() function:
Translation = _beginPosition.LinearInterpolate(Destination,_currentTranslationTime/Time);
The result was the same as with Tween.
I think I missed something, I thought it was an easy thing to move object linearly between two positions.
Thanks for your help.