Hi I’m trying to make a player’s y position increase by when a certain number when a button pressed so i created 2 functions but when I press then, the y changes but the player’s position also get’s reset to it’s starting position. I have included a video and the code, does anyone know what’s wrong?
https://drive.google.com/file/d/1hYn1i6CD9zBjQO-5eDgV7TmzORX4H-gy/view?usp=sharing
ing System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveY : MonoBehaviour
{
public Transform playerTransform;
public Vector2 playerY;
public Vector2 PlayerY2;
float goneUp = 0;
float goneDown = 0;
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void ButtonUp()
{
if (goneUp < 1)
{
playerTransform.position = playerTransform.position * PlayerY2;
goneUp = goneUp + 1;
goneDown = 0;
}
}
public void ButtonDown()
{
if (goneDown < 1)
{
playerTransform.position = playerTransform.position * playerY;
goneDown = goneDown + 1;
goneUp = 0;
}
}
}