- Home /
This question was
closed May 18, 2020 at 04:11 AM by
Jeezker for the following reason:
Other
Question by
Jeezker · May 18, 2020 at 02:39 AM ·
physicsrigidbodytouch controlstouchphase
Set Rigidbody.velocity.x with Touch? All devices same speed.
Hi,
I am having problems moving an object left/right changing Rigidbody.velocity with Input.touch.
It works fine, but the speed is not the same on all devices / resolutions.
Please help me!
// INPUT
if (Input.touchCount > 0)
{
Touch touch = Input.GetTouch(0);
if (touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Began)
xVel = touch.deltaPosition.x * moveSpeed;
else if (touch.phase == TouchPhase.Stationary)
xVel = 0f;
}
After this, I am setting the velocity using that xVel variable: rb.velocity = new Vector3(xVel, yVel, zVel);
Comment