First Post to this forum, first attempt at C# & Unity so I appreciate any/all feedback. I am trying to create a dice game and want to determine which side of the rigidbody has the highest Y directional axes and return that face value. I currently get a warning sign saying unreachable code detected and do not have any value returned for my y axes.
here is my current code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ApplyForceInRandomDirection : MonoBehaviour {
public string buttonName = "Fire1";
public float forceAmount = 10.0f;
public ForceMode forceMode;
public Rigidbody rb;
public float torqueAmount = 10.0f;
public Vector3 dieDirection;
void Start()
{
rb = GetComponent<Rigidbody>();
dieDirection = rb.transform.TransformDirection(0,0,0);
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown (buttonName)) {
rb.AddForce (Random.onUnitSphere*forceAmount, forceMode);
rb.AddTorque (Random.onUnitSphere*torqueAmount, forceMode);
}
}
public Vector3 GetDirection(float x, float y, float z){
return transform.TransformDirection (dieDirection);
print (y);
}
}