Example #1
0
 void CheckIfMoveFinished()
 {
     if (Vector3.Distance(startingPosition, transform.position) >= desiredDistance || Time.time > timeToEnd ||
         Time.time > timeOfStart + timeOut)
     {
         movementDesired = false;
         ControllScript.GetInstance().notifyRobotReady();
     }
 }
Example #2
0
 // Start is called before the first frame update
 void Start()
 {
     sensor = GetComponentInChildren <SensorSuite>();
     rigid  = GetComponent <Rigidbody>();
     Rotate(-30);
     gameObject.layer = Physics.IgnoreRaycastLayer;
     ControllScript.GetInstance().RegisterRobot(this);
     ControllScript.GetInstance().notifyRobotReady();
 }
Example #3
0
    void OnDestroy()
    {
        try
        {
            Destroy(gameObject, .2f);

            ControllScript.GetInstance().DeRegisterGhost(this);
        }
        catch (System.Exception e)
        {
        }
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        if (rotationDesired)
        {
            rigid.AddTorque(0, currentTorque, 0);
            float virtualRotation        = transform.rotation.eulerAngles.y;
            float virtualDesiredRotation = desiredRotation;
            if (Mathf.Abs(lastFrameRotation - virtualRotation) > 50)
            {
                needsToCrossThreshold = false;
            }
            lastFrameRotation = virtualRotation;
            if (!needsToCrossThreshold && currentTorque > 0 && virtualRotation > virtualDesiredRotation)
            {
                rotationDesired = false;
                ControllScript.GetInstance().notifyRobotReady();
            }

            if (!needsToCrossThreshold && currentTorque < 0 && virtualRotation < virtualDesiredRotation)
            {
                rotationDesired = false;
                ControllScript.GetInstance().notifyRobotReady();
            }
        }

        if (!movementDesired)
        {
            return;
        }
        rigid.AddForce(transform.forward * desiredPower);
        if (rigid.velocity.magnitude > MaxVelocity)
        {
            rigid.velocity.Normalize();
            rigid.velocity *= MaxVelocity;
        }

        CheckIfMoveFinished();
    }
Example #5
0
 void Start()
 {
     ControllScript.GetInstance().RegisterGhost(this);
 }