// Update is called once per frame void Update() { switch (thisState) { case (diceState.landed): xRS = 0; yRS = 0; zRS = 0; if (Input.GetKeyDown(KeyCode.J)) { ThrowUp(); xRS = Random.Range(0f, 1f) * spinFactor; yRS = Random.Range(0f, 1f) * spinFactor; zRS = Random.Range(0f, 1f) * spinFactor; //Debug.Log("RotxSpd: " + xRS.ToString() + " RotySpd: " + yRS + " RotzSpd: " + zRS.ToString()); } if (_inputManager.OneFinger()) { Tapped(); xRS = Random.Range(0f, 1f) * spinFactor; yRS = Random.Range(0f, 1f) * spinFactor; zRS = Random.Range(0f, 1f) * spinFactor; //Debug.Log("RotxSpd: " + xRS.ToString() + " RotySpd: " + yRS + " RotzSpd: " + zRS.ToString()); } Debug.Log("Dice: landed"); break; case (diceState.falling): SpinMeRound(xRS, yRS, zRS); Debug.Log("Dice: falling"); break; case (diceState.thrown): SpinMeRound(xRS, yRS, zRS); if (RB.velocity.y <= 0) { thisState = diceState.falling; } Debug.Log("Dice: thrown"); break; default: if (RB.velocity.y <= 0) { thisState = diceState.falling; } Debug.Log("No diceState"); break; } RaycastHit hit; Ray ray = new Ray(this.transform.position, Vector3.up * raydebugdist); Debug.DrawRay(ray.origin, ray.direction * raydebugdist, Color.black); if (Physics.Raycast(ray.origin, ray.direction, out hit)) { string number = hit.collider.name; print(number); numberInt = WhatDiceNumber(number); } }
void OnCollisionEnter(Collision collision) { if (thisState == diceState.falling) { if (collision.gameObject.transform.position.y <= this.transform.position.y) { Debug.Log(collision.gameObject.tag); thisState = diceState.landed; } } }
public void ThrowUp() { RB.AddForce(Vector3.up * force); thisState = diceState.thrown; }