when I press a button the object moves down and when I releases the button(Eventrigger Pointer UP) my gameobject moves up . but when it reached
the condition:
if (destPos.y > origPos.y)
{
vInput = 0f;
}
After this function is called I press the button but it no longer works.
how can i make it work everytime i presses the button and i want to limit that the y position of destPos will not be greater than y axis of origPos. Hope someone can help me with this. Thanks in advance!
void Update()
{
if (origPos.x != 0) {
Debug.Log(destPos.x);
destPos = origPos;
}
destPos.x = origPos.x;
origPos = new Vector2 (origin.transform.position.x, origin.transform.position.y);
destPos = new Vector2 (destination.transform.position.x, destination.transform.position.y);
if (destPos.y > origPos.y)
{
vInput = 0f;
}
}
void FixedUpdate()
{
Move(vInput);
}
public void Move(float verticalInput )
{
Vector2 moveVel = myBody.velocity;
moveVel.y = verticalInput * speed;
myBody.velocity = moveVel;
}
public void StartMoving(float verticalinput)
{
vInput = verticalinput;
}
}