Esempio n. 1
0
	private IEnumerator StealPotatoRoutine()
	{
        //TODO: check if there potato is already used
		potato = potatoes.StealPotato();

		if (potato != null)
		{
			Vector3 dir = potato.transform.position - transform.position;
			dir = Vector3.ProjectOnPlane(dir, Vector3.up);

			armPivotTransform.forward = dir;

            while(Vector3.Distance(clawTransform.position, potato.transform.position) > 0.1f)
            {
                Vector3 stealDir = potato.transform.position - clawTransform.position;
                potato.transform.position -= stealDir.normalized * 1.5f * Time.deltaTime;
                yield return new WaitForEndOfFrame();
            }
            potato.transform.SetParent(transform);
			potatoes.PotatoStolenSuccessfully(potato);
		}


		carState = State.Escape;

		stealRoutine = null;
	}
Esempio n. 2
0
    private IEnumerator StealPotatoRoutine()
    {
        //TODO: check if there potato is already used
        potato = potatoes.StealPotato();

        if (potato != null)
        {
            transform.LookAt(potato.transform);

            while (Vector3.Distance(clawTransform.position, potato.transform.position) > 0.1f)
            {
                Vector3 stealDir = potato.transform.position - clawTransform.position;
                potato.transform.position -= stealDir.normalized * 1.5f * Time.deltaTime;
                yield return(new WaitForEndOfFrame());
            }
            potato.transform.SetParent(transform);
            potatoes.PotatoStolenSuccessfully(potato);
        }

        batState = State.Escape;

        stealRoutine = null;
    }