//transform.position topun pozisyonu | deltaPosition aradaki farkı alan. | speedModifier int ile çarpıyor.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour.
{
public GameObject cam;
private Rigidbody rb;
private Touch touch;
[Range(20,40)]
public int speedModifier;
public int forwardSpeed;
public void Start()
{
rb = GetComponent<Rigidbody>();
}
public void Update()
{
if (Variables.firsttouch == 1)
{
transform.position += new Vector3(0,0, forwardSpeed * Time.deltaTime);
}
if (Input.touchCount > 0)
{
touch = Input.GetTouch(0);
if (touch.phase = TouchPhase.Began)
{
Variables.firsttouch = 1;
}
else if (touch.phase == TouchPhase.Moved)
{
rb.velocity = new Vector3(touch.deltaPosition.x * speedModifier * Time.deltaTime,
transform.position.y,
touch.deltaPosition.y * speedModifier * Time.deltaTime);
}
else if(touch.phase == TouchPhase.Ended)
{
//rb.velocity = new Vector3(0, 0, 0);
rb.velocity = Vector3.zero;
}
}
}
}