hi everyone,
I have a sript for rotating my camera, but I dont want it to start immedeatly rather like 5 seconds after the application launch. I wish for it to loop the script after 20 seconds how do I do theese 2 things? this is the code I have now:
var Moving = pc.createScript(‘moving’);
// initialize code called once per entity
Moving.prototype.initialize = function() {
};
// update code called every frame
Moving.prototype.update = function(dt) {
this.entity.translateLocal(0, 0, 0);
this.entity.rotateLocal(0.2,0,0);
};
thanks a lot @yaustar!
a new problem occured… I want the 0.2 rotation to keep going for another 5 seconds and then stop.
then after 5 seconds stop i wish for the script to start over again.
In which case, you can use the same logic as above to keep track of how long it has been rotating for and stopped for. You will also need to keep track of whether it is ‘stopping’ or ‘rotating’ mode too.
You do not reset the script as such, but you simply reset the values that script changes. For example, you have some angle that is somehow changed by the script when your application is running. To reset the script, you simply check for some condition to meet (like some time passes or some event happens) and you reset that angle back to its original value. @yaustar gave you a good example of how to do something after some time passes.