//assigning references private void InitializePlayerComponents() { //get all components to manage _movement = this.GetComponent<PlayerMove>(); _life = this.GetComponent<PlayerLife>(); _pushPull = this.GetComponent<PushPull>(); //tell all components this is their controller AssignController(this); }
public override void Start(RAIN.Core.AI ai) { GameObject p = GameObject.FindGameObjectWithTag("Player"); GameObject cabbageGuy = GameObject.Find("CabbageGuy"); Player.PlayerMove pm = p.GetComponent <Player.PlayerMove>(); ct = cabbageGuy.GetComponent <CabbageThrow>(); Vector3 predictVector = p.transform.position + p.transform.forward.normalized * 1f * pm.maxSpeed * (pm.animator.GetFloat("Speed") / 2); Vector3 predicPosDif = predictVector - cabbageGuy.transform.position; ct.cabbage_force = predicPosDif.magnitude * 68; ct.predictVector = predicPosDif.normalized; base.Start(ai); }