First of all I am new to unity I just jumped off Game Maker and start learning unity3D and I followed some of tutorial in Learn I find it very different than game maker but I was also pretty impressed how easy and fun it is to learn
Now I want to create a fortune wheel for my game using C# so, does anyone know how create a fortune wheel where you could drag/rotate it with mouse.
Ok, I write this code in C# it works good but the only problem is I donāt know how to add acceleration to it so that if I release the mouse button it should still continue rotating and slow down until it fully stopped (Just like a realistic Fortune Wheel).
any help plz?
using UnityEngine;
using System.Collections;
public class RotateCSharp : MonoBehaviour
{
public int speed;
public float lerpSpeed;
float xDeg;
float yDeg;
Quaternion fromRotation;
Quaternion toRotation;
void Update()
{
if (Input.GetMouseButton(0))
{
xDeg -= Input.GetAxis("Mouse X") * speed;
fromRotation = transform.rotation;
toRotation = Quaternion.Euler (yDeg,xDeg,0);
transform.rotation = Quaternion.Lerp(fromRotation, toRotation, Time.deltaTime * lerpSpeed);
}
}
}
Thatās because all your code is inside the if clause. You can put an āelseā clause with the same code. So you might use something like a startSpeed and then in the input clause: xDeg = startSpeed. It wouldnāt start slowing down until you released the mouse button, I donāt think, it would just turn at the same speed while holding it down.
sorry didnāt catch it well as I said I am new to Unity as will as C#, it will be easier for me if you could explain it or even us it in script so that i could understand it.