Hi Guys, Im having issues trying to create a 2D wheel of fortune, see the below video for the problem: Notice that the "Clacker" gets stuck and pulls away from its hinge point. To simulate this I am using a hinge joint and two sping joints on the clacker and the wheel contains a number of pegs which are non-kinematic circle colliders. I have also added a distance joint to the clacker to try and force it to stay where it is but to no avail. Can anyone think of a better way of doing this?
Scratch that. I worked it out. Incase anyone wants to do something simmilar, make sure the "pegs" dont have a rigidbody an give the wheel a hinge joint
Hey, would it be possible for you to post the project? (Or the spinning wheel part, for the matter). I'm trying to do one, too, but I'm hitting a wall in several ways :x
@Mikeysee I am making a similar spinning wheel and the spinning worked, but my problem is that how can I know what item was chosen at the end ? Can you tell me how to do it ? EDIT: Nevermind. I found a way to do it. Just add a triggered 2d collider ( I added a polygon collider) on an empty gameobject and put it above each item. And after the spinning is finished, detect to which collider the clacker has collided.
Hi Guy's I'm trying to get the spinner work with a button like yours on click but can't seem to get it. I'm using a code that I got from the appguruz. here is the code using UnityEngine; using System.Collections; using System.Collections.Generic; public class SpinWheel : MonoBehaviour { public List<int> prize; public List<AnimationCurve> animationCurves; private bool spinning; private float anglePerItem; private int randomTime; private int itemNumber; void Start(){ spinning = false; anglePerItem = 360/prize.Count; } void Update () { if (Input.GetKeyDown (KeyCode.Space) && !spinning) { randomTime = Random.Range (1, 4); itemNumber = Random.Range (0, prize.Count); float maxAngle = 360 * randomTime + (itemNumber * anglePerItem); StartCoroutine (SpinTheWheel (5 * randomTime, maxAngle)); } } IEnumerator SpinTheWheel (float time, float maxAngle) { spinning = true; float timer = 0.0f; float startAngle = transform.eulerAngles.z; maxAngle = maxAngle - startAngle; int animationCurveNumber = Random.Range (0, animationCurves.Count); Debug.Log ("Animation Curve No. : " + animationCurveNumber); while (timer < time) { //to calculate rotation float angle = maxAngle * animationCurves [animationCurveNumber].Evaluate (timer / time) ; transform.eulerAngles = new Vector3 (0.0f, 0.0f, angle + startAngle); timer += Time.deltaTime; yield return 0; } transform.eulerAngles = new Vector3 (0.0f, 0.0f, maxAngle + startAngle); spinning = false; Debug.Log ("Prize: " + prize [itemNumber]);//use prize[itemNumnber] as per requirement } }
any Ideas, also I would like to fill the wheel with images when clicked on and make it a multiplayer game.
Sorry to reply so late. Has everyone solve their own issue or do you need some of my help with something?