Answer the question
In order to leave comments, you need to log in
Why does an object pass through other objects, leads incomprehensibly?
Instead of the object spinning around its axis by 360 while maintaining the Physics Material 2D component (while the torsion is reproduced by the touch screen), it flies up, passes through the floor, instead of spinning around its axis.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SwipeRotate : MonoBehaviour
{
public float speed;
Vector2 pos;
private void Start()
{
speed = 2;
}
private void Update()
{
if (Input.touchCount > 0)
{
Touch touch = Input.GetTouch(0);
Vector2 posInScreen = touch.position;
if (touch.phase == TouchPhase.Moved)
{
pos = (posInScreen);
}
float Xposition = pos.x;
transform.rotation = Quaternion.Euler(0, 0, Xposition * speed);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question