Example #1
0
    public float calculdistance(Vector3 position)
    {
        Tankcontrol tank = this.gameObject.GetComponentInParent <Tankcontrol>();

        distance = Vector3.Distance(position, tank.transform.position);
        return(distance);
    }
Example #2
0
    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);
    }