Search Unity

Fake and control a random Spin

Discussion in 'Scripting' started by Simon75012, Oct 25, 2018.

  1. Simon75012

    Simon75012

    Joined:
    Sep 15, 2016
    Posts:
    79
    Hi,
    I'm working to fake a result on a Jackpot Wheel (UI element).
    Right now a add a Rigidbody2D and do :
    rigidWheel.AddTorque(UnityEngine.Random.Range(2000,9000));

    So my result is random, i don't know before the wheel stop what will be the final rotation of my RectTransform.
    I'd like to change that and know what will be the result at the beginning of the spin to control a bit, to avoid a stop at the same result twice in a row.

    I'm not sure if i can do this with the rigidbody2D. I don't mind using an other component for this (I just use the rigidbody2D for this purpose).

    I'm out of idea to solve my problem, i just found crapy solutions like check when the angularVelocity is low and put angularDrag to 0 when the wheel is over the previous result... But the animation become cheap :)

    Thanks.
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    I would imagine a roulette wheel in Unity is a chaotic system, making it almost impossible to predict in advance. You are likely going to have to cheat the whole thing.