Quantcast
Channel: Questions in topic: "invokerepeating"
Viewing all articles
Browse latest Browse all 220

Why does Debug.Log continue to execute from Start() and why does InvokeRepeating() not?

$
0
0
While trying to figure out why InvokeRepeating() doesn't execute I noticed the line: Debug.Log("Initial moveSpeed: " + moveSpeed); continuously executes. using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlatformControl : MonoBehaviour { [SerializeField] float moveSpeed; private Vector3 randomRotation; private Rigidbody platformRigidbody; private float removePositionZ; // Start is called before the first frame update void Start() { moveSpeed = 1500f; platformRigidbody = GetComponent(); randomRotation = new Vector3(Random.Range(0f, 15f), Random.Range(-25f, 25f), 0f); transform.Rotate(randomRotation); removePositionZ = Camera.main.transform.position.z; Debug.Log("Initial moveSpeed: " + moveSpeed); // This line is the issue... why? // After ten seconds begin to increase moveSpeed every second //InvokeRepeating("MoveSpeedControl", 10.0f, 1.0f); } // Update is called once per frame void Update() { MovementControl(); } void MovementControl() // Controls platform movement { Vector3 movementVector = new Vector3(0f, 0f, moveSpeed * Time.deltaTime); platformRigidbody.velocity = movementVector; if(transform.position.z > removePositionZ){ Destroy(gameObject); } } void MoveSpeedControl() { Debug.Log("Enter MoveSpeedControl"); while(moveSpeed < 2000) { moveSpeed += 1; Debug.Log("Current Move Speed: " + moveSpeed); } } } At first I thought the InvokeRepeating() was somehow interfering (hence why it is commented out) but that isn't the case. I'm hoping,I have been having trouble getting the InvokeRepeating to execute; I use it in another script without issue but this one doesn't seem to cooperate. I'm hoping someone else can see what I cannot. Thanks for the assistance!

Viewing all articles
Browse latest Browse all 220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>