IEnumerator InternalSpawn() { float spawnTime = minSpawnInterval + Random.value * maxSpawnInterval; yield return(new WaitForSeconds(spawnTime)); if (gsc.IsRunning()) { targetPosition = new Vector3(movePosX, 0, 0); velocity = Vector3.zero; spawned = true; } }
// Update is called once per frame void Update() { if (gsc.IsRunning()) { transform.position = new Vector3(transform.position.x + velocidadeAviaoDiff, transform.position.y + Mathf.Sin(Time.time * 2) * vooAviaoDiff, transform.position.z); } }
void Update() { if (gsc.IsRunning()) { if ((Input.GetMouseButtonDown(0) || Input.GetKeyDown("space")) && jumpCounter > 0) { //removendo todas as forças pra fazer "pulo limpo" this.GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0); this.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, jumpForce)); this.jumpCounter--; anim.Play("PlayerJumping", -1, 0f); } /* Acelerando player pra direita */ this.GetComponent <Rigidbody2D>().velocity = new Vector2(moveVelocity, this.GetComponent <Rigidbody2D>().velocity.y); /* Travando angulo para objeto nao rotacionar */ transform.eulerAngles = new Vector3(0, 0, 0); } }