public float calculdistance(Vector3 position) { Tankcontrol tank = this.gameObject.GetComponentInParent <Tankcontrol>(); distance = Vector3.Distance(position, tank.transform.position); return(distance); }
public void turnforward() { Tankcontrol tank = this.gameObject.GetComponentInParent <Tankcontrol>(); Turretforward tforward = tank.GetComponentInChildren <Turretforward>(); Quaternion forward = Quaternion.LookRotation(transform.position - tforward.transform.position); forward.x = 0; forward.z = 0; transform.rotation = Quaternion.Slerp(transform.rotation, forward, Time.deltaTime * 2.0f); }