void Throw() { source.PlayOneShot(throwSound); state = knifeState.THROWING; currentKnife = Instantiate(knife, transform.position + Camera.main.transform.forward + new Vector3(0, 1f), Quaternion.Euler(transform.rotation.eulerAngles + new Vector3(0, 90, 270))); currentKnife.GetComponent <KnifeBehaviour>().SetOwner(this.gameObject); currentKnife.GetComponent <Rigidbody>().velocity = 20 * Camera.main.transform.forward; }
void Update() { if (Input.GetMouseButtonDown(0) && state == knifeState.INHAND) { Throw(); GameObject.Find("Cursor").GetComponent <Image>().color = Color.red; } else if (Input.GetMouseButtonDown(0) && state == knifeState.INGROUND) { Destroy(currentKnife); state = knifeState.INHAND; } }
public void SetState(knifeState state) { this.state = state; }
public bool CheckIfState(knifeState state) { return(this.state == state); }