anirus 0 Share Posted April 26, 2018 Hello, I am new to scripting and have just started programming my first script. I have little Java experience but my script works, however I want to implement a piece of code which moves the camera at different times without interrupting the whole script. I set up a variable that randomly switches between two numbers, depending on what number it'll move the camera to a new position, however I dont want the camera to be moving 24/7. I want this to occur maybe somewhere between 10-60 secs. I tried adding a sleep in but then the whole script would sleep. Any way to implement a sleep into a while loop that doesn't effect the rest of the script? Link to comment Share on other sites More sharing options...
Manly 879 Share Posted April 26, 2018 Sounds like what you're looking for is a thread. If you don't want to go with this approach, you can use a timer object to handle this in the main loop. Link to comment Share on other sites More sharing options...
anirus 0 Author Share Posted April 27, 2018 19 hours ago, Man16 said: Sounds like what you're looking for is a thread. If you don't want to go with this approach, you can use a timer object to handle this in the main loop. To use a thread would I have to create a new class within the program? Also thank you. Link to comment Share on other sites More sharing options...
Manly 879 Share Posted April 27, 2018 6 minutes ago, anirus said: To use a thread would I have to create a new class within the program? Also thank you. https://docs.oracle.com/javase/tutorial/essential/concurrency/runthread.html Link to comment Share on other sites More sharing options...
anirus 0 Author Share Posted April 28, 2018 8 hours ago, Man16 said: https://docs.oracle.com/javase/tutorial/essential/concurrency/runthread.html Thank you, this worked. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.