New answers tagged

0

you can use this code: UnityEngine.SceneManagement.SceneManager.LoadScene( UnityEngine.SceneManagement.SceneManager.GetActiveScene().name);


2

To restart your current scene, you need current scene index or name. And once you have the current scene index or name then just reload it. Here the example that how i done it: public void RestartCurrentScene() { int currentScene = SceneManager.GetActiveScene().buildIndex; SceneManager.LoadScene(currentScene); } Add this to the very top ...


0

The reason you see the rapid back and forth movement as it tried to align itself to the player's axis is because of overshoot, as you probably guessed. I reconstructed what I believe you are trying to do using Vector3.MoveTowards instead. This function is useful because it does not overshoot. Unfortunately this code is untested so let me know if it works. ...


1

After advice from Alexandre Vaillancourt, my earlier comment is now turned into an answer. If performance is an issue, you might wanna use a design method/pattern called Object pooling. What this method/pattern actually means is that you, at the start-up of the game/level/scene, fill a container (an std::vector, an std::list etc) with a fixed number of ...


4

You're using a std::vector<Bullet>. This has the advantage of keeping data contiguous in memory, so iterating over it is fast (it has something to do with cache efficiency vs cache misses). The way you're using it is slow. auto it = Bulletlist.begin(); while (it != Bulletlist.end()) { if ((it->del)) { it = Bulletlist.erase(it); } else ...


0

You're updating your lastTime / lastTimeDataGathered values inside your fixed update loops, rather than every time you accumulate a time interval. That means the interval you add to your simulationDelta and gatherDataDelta accumulators keeps growing with every cycle. So the first loop after a simulation update, you add one outer loop's worth of time to the ...


Top 50 recent answers are included