using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerScript : MonoBehaviour
{
private bool isInGame = false;
private Rigidbody2D myRB;
Vector2 tempPos;
private bool isRight = false;
private void Start()
{
myRB = GetComponent<Rigidbody2D>();
}
private void FixedUpdate()
{
Debug.Log(isRight);
Debug.Log(myRB);
if (isRight)
{
if (Input.GetKeyDown(KeyCode.RightArrow)) # DOESNT WORK: Input.GetMouseButtonDown(0)
{
tempPos = transform.position;
tempPos.x += 2.0f;
transform.position = tempPos;
isRight = false;
}
}
if (!isRight)
{
if (Input.GetKeyDown(KeyCode.LeftArrow)) # DOESNT WORK: Input.GetMouseButtonDown(0)
{
tempPos = transform.position;
tempPos.x += -2.0f;
transform.position = tempPos;
isRight = true;
}
}
if (!isInGame)
return;
}
public void InitGame()
{
isInGame = true;
}
}