Question by
Joystick_MoJo · Jul 03, 2017 at 05:52 AM ·
transformpositionvector3programminglerp
gameobject position lerp
i want to move an object between 2 point , but i am really confused CODE
public float jumpHeight = 2f;
public float movementRange =2f;
Vector3 jumpForward;
Vector3 jumpBackward;
public float lerpSpeed = 0.5f;
Vector3 jumpForwardLerp;
Vector3 jumpBackwardLerp;
void Start ()
{
jumpForward = new Vector3 (0, jumpHeight, movementRange);
jumpBackward = new Vector3 (0, jumpHeight, -movementRange);
}
void Update ()
{
//Vector Update
jumpForwardLerp = player.transform.position + jumpForward;
jumpBackwardLerp = player.transform.position + jumpBackward;
if (Input.GetKeyUp (KeyCode.RightArrow))
{
player.transform.position = Vector3.Lerp(player.transform.position, jumpForwardLerp , lerpSpeed);
}
else if (Input.GetKeyUp (KeyCode.LeftArrow))
{
player.transform.position = Vector3.Lerp(player.transform.position, jumpBackwardLerp , lerpSpeed);
}
i just started programming so i dont know what went wrong please help
Comment