Question by
swastika_pallai · Jan 28, 2021 at 08:33 AM ·
unity 5
Why does the player stops rotating in the middle ?
Hi, I want my character to rotate hrough mouse drag. I wrote the code and while testing it, my player only rotates a bit (left or right) and then stops rotating. Here's my code that rotates my player based on mouse drag:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class myScript : MonoBehaviour
{
public float speed;
public GameObject player;
private void Start()
{
speed = 2f;
}
private void Update()
{
player.transform.Rotate(0, speed * Input.GetAxis("Mouse X"), 0);
}
}
I don't know why it happens.. pls help.
Comment
Your answer
Follow this Question
Related Questions
how to make a procedural flower? 1 Answer
"Object reference not set to the instance of an object" 0 Answers
Error :Currently selected backend ill2ccp not installed (UWP) 0 Answers
How to add a Animator Controller to a character at runtime? 0 Answers
Keyboard input works in editor, but not when built 0 Answers