Object completely losing orientation using Lerp
So, I am making a 2d board game. Basically, two characters are moving on the board when clicking a spot on the board. Since it's a static one frame 2d game, I put all of my game objects children of the canvas. All the positions seems to be aligned, in the canvas itself everything is in place, also when I am debugging I notice that both of the positions, the local position and the target position are correct, so when I'm not using lerp and just setting the character position to the target position, it works perfect.
this is the Update function of the Player class:
private void FixedUpdate()
{
if (moveTowards == true)
{
velocity = Vector3.zero;
this.transform.position = Vector3.SmoothDamp(this.transform.localPosition, targetSpotPosition, ref velocity, .08f);
}
if (this.transform.position == targetSpotPosition)
{
moveTowards = false;
}
}
moveTowards sets to true when clicking a spot.
public void movePlayerTo(Spots moveHere)
{
moveTowards = true;
targetSpotPosition = moveHere.transform.position;
}
moveHere is the spot's position, there's no problem there.
Lerp/Smooth damp are working perfect outside the canvas I think it's something related to the update function, as it's updating false positions, but that's all I can guess...
I set my canvas to camera space render mode, and of course scale with screen size.
HELP PLEASE. Thanks in advance,
Omer
Your answer
Follow this Question
Related Questions
Weapon does't meet the target position when using IK 1 Answer
I can't figure out smoothing a rotational move. Tried lerp, slerp, all the stuff. 0 Answers
Simple Advice needed - Lerp, SmoothDamp, SmoothStep...... etc. 2 Answers
Interpolated movement in a circle 1 Answer
Is there a way to smoothly change a float number between two numbers when a key is pressed? 1 Answer