Hello everyone,
no idea why img link doesnt work but i will post it here.
I am trying to make my char to do a jump animation when the player presses left or right once, and it will jump to that platform.
Right now I am able to do it by transforming the position from A to B at once, but how do I make it from A to B by 2 seconds ( doesnt really matter )
Any help is appreciated!!
//check the upcoming platform
selectLeft = Physics2D.Linecast(checkLeftS.position, checkLeftF.position, 1 << LayerMask.NameToLayer("select"));
selectRight = Physics2D.Linecast(checkRightS.position, checkRightF.position, 1 << LayerMask.NameToLayer("select"));
if (selectLeft.collider != null)
{
// Debug.Log(selectLeft.collider.name + " is in front of " + gameObject.name);
tempL = new Vector3(selectLeft.transform.position.x, selectLeft.transform.position.y - 1);
canGoLeftS = true;
}
else
{
canGoLeftS = false;
}
if (selectRight.collider != null)
{
//Debug.Log(selectRight.collider.name + " is in front of " + gameObject.name);
tempR = new Vector3(selectRight.transform.position.x, selectRight.transform.position.y - 1);
canGoRightS = true;
}
else
{
canGoRightS = false;
}
//player input here
if (Input.GetKeyDown("right") && canGoRightS)
{
transform.position = tempR;
// Debug.Log("go right");
}
if (Input.GetKeyDown("left") && canGoLeftS)
{
transform.position = tempL;
// Debug.Log("go left");
}
!(http://
)