// Use this for initialization void Start() { //body = GetComponent<Rigidbody>(); //state = State.MOVING_RIGHT; state = GetComponent <TeddyState>(); player = GameObject.FindObjectOfType <Player>();//GetGame<Player>(); state.selectable = false; _wisp = null; }
// Use this for initialization void Start() { //body = GetComponent<Rigidbody>(); //state = State.MOVING_RIGHT; state = GetComponent<TeddyState>(); player = GameObject.FindObjectOfType<Player>();//GetGame<Player>(); state.selectable = false; _wisp = null; }
public void UnTarget() { TeddyState teddy_state = _target.GetComponent <TeddyState>(); if (teddy_state) { teddy_state.state = TeddyState.State.DEAD; } _target = null; _wisp.UnSetTarget(); }
void Update() { // look at the mouse (rotate head to face the mouse pointer) Vector3 mousePos = Input.mousePosition; Vector3 pos = Camera.main.WorldToScreenPoint(transform.position); mousePos = mousePos - pos; _head.transform.rotation = Quaternion.Euler(new Vector3(0, 0, Mathf.Atan2(mousePos.y, mousePos.x) * Mathf.Rad2Deg)); // Check to see if we're grounded RaycastHit hit; LayerMask mask = 1;//~LayerMask.NameToLayer("Bears"); if ((Physics.Raycast(new Ray(transform.position + new Vector3(0.0f, 0f, 0f), new Vector3(0f, -1.0f)), out hit, mask) && hit.distance < 0.5f) || (Physics.Raycast(new Ray(transform.position + new Vector3(0.5f, 0f, 0f), new Vector3(0f, -1.0f)), out hit, mask) && hit.distance < 0.5f) || (Physics.Raycast(new Ray(transform.position + new Vector3(-.5f, 0f, 0f), new Vector3(0f, -1.0f)), out hit, mask) && hit.distance < 0.5f)) { if (_jumping && !_grounded) { Debug.Log("RYAHI"); _animator.SetBool("isJump", false); _jumping = false; } _grounded = true; } else { _grounded = false; } // Unselect the current target if it's dead or out of range if (_target) { TeddyState target_state = _target.GetComponent <TeddyState>(); if (target_state && target_state.state == TeddyState.State.DEAD || (transform.position - _target.transform.position).magnitude > target_state.max_living_dist_from_player) { UnTarget(); } } }
// Use this for initialization void Start() { //body = GetComponent<Rigidbody>(); //state = State.MOVING_RIGHT; state = GetComponent <TeddyState>(); }
// Use this for initialization void Start() { //body = GetComponent<Rigidbody>(); //state = State.MOVING_RIGHT; state = GetComponent<TeddyState>(); }