Can I make an object move at the same speed as touch using Rigidbody.MovePosition()?
This is what I'm currently using(rb is the relevant items rigid body).
void FixedUpdate() {
float h = horizontalSpeed * Input.GetAxis("Mouse X") * Time.deltaTime;
float v = verticalSpeed * Input.GetAxis("Mouse Y") * Time.deltaTime;
newPosition = transform.position;
newPosition.x += h;
newPosition.z += v;
rb.MovePosition(newPosition);
}
Also can I make it so that when the user lets go of the screen and touches it again the item just moves as the touch does and it doesn't jump. The z position is locked.
I'm using the move position as I need it not to pass through walls.
Comment