Follow These Steps to Rotate Player
this is very easy method to rotate our player in main menu like free fire or pubg game. implement this work to follow some steps...
- First we need 3d model that we rotate
- Set camera position near the model.like this image
3.Have no need any other components.
4.Add this script to 3d model.
/////////////////////////////////////////////////////////............/////////////////////////////////////////////////////////////
using UnityEngine;
public class Rotate : MonoBehaviour {
private Touch touch;
private Vector2 touchPosition;
private Quaternion rotationY;
private float rotateSpeedModifier = 0.1f;
// Update is called once per frame
void Update()
{
if (Input.touchCount > 0)
{
touch = Input.GetTouch(0);
Debug.Log("Rotate");
if (touch.phase == TouchPhase.Moved)
{
rotationY = Quaternion.Euler (
0f,
- touch.deltaPosition.x * rotateSpeedModifier,
0f);
transform.rotation = rotationY * transform.rotation;
}
}
}
}
/////////////////////////////////////////////////////////............/////////////////////////////////////////////////////////////
5.This script test only your Phone,like this
6.I hope you enjoy this post and something learn.
/////////////////////////////////////////////////////////............/////////////////////////////////////////////////////////////
using UnityEngine;
public class Rotate : MonoBehaviour {
private Touch touch;
private Vector2 touchPosition;
private Quaternion rotationY;
private float rotateSpeedModifier = 0.1f;
// Update is called once per frame
void Update()
{
if (Input.touchCount > 0)
{
touch = Input.GetTouch(0);
Debug.Log("Rotate");
if (touch.phase == TouchPhase.Moved)
{
rotationY = Quaternion.Euler (
0f,
- touch.deltaPosition.x * rotateSpeedModifier,
0f);
transform.rotation = rotationY * transform.rotation;
}
}
}
}
/////////////////////////////////////////////////////////............/////////////////////////////////////////////////////////////
5.This script test only your Phone,like this
6.I hope you enjoy this post and something learn.
0 Comments