- Home /
Pausing a particular game object and unpausing.
Hi, is it possible to make particular sets of game objects to pause during the game? I'm trying to do pause and unpause particular objects. Any ideas? Thank you!
How are you moving your game objects? Rigidbody, character controller, or Translating? Are you going to have different buttons pause different things, or only a single pause for this group of game objects?
$$anonymous$$ost of them are rigid body. Only a single pause for this group of game objects. Is there unity defined function for that? or should we have to do manually? I don't want them to update at particular point.
There is no Unity function for this. You will have to do them individually. You will have to figure out how to communicate to these scripts that a pause is in progress...a static variable, a common script they referecne...and then have each individual object pause (or an outside script pause for them). For pausing a Rigidbody, you might try setting the is$$anonymous$$inematic flag to true.
Answer by Nerull22 · Mar 25, 2013 at 03:33 AM
A solution to a pause for a certain group of objects is to relate their movement to time, and then set the timescale to 0. So a movement times 0 will always be zero. Shrugs I've done something like this in the past and it works pretty well, just depends on what you're doing I suppose.
Not just movement, I want entire functions to shut down. For example, I want to stop updating enemies, it should stop spawning them, shooting bullets etc.
All right, this may not be the only solution, but I think it may be a solution for this particular problem. You can create a class that extends $$anonymous$$onoBehaviour. And set up in the update an if statement that will only run if a certain boolean is set to true. And have another update that you create such as "Run()" that will act as your update. So...
bool shouldRun;
void Update()
{
if(shouldRun)
Run();
}
void Run()
{
//Override this function
}
Then all the actions that you would want the object to take on a normal running will be placed in the overriden function of Run. So then all you have to do is make a call to the inherited parents variable of shouldRun to stop it from calling that scripted data. Could even set up a global variable to do this maybe....
I'm hoping that what I have said makes sense and helps.
Answer by schetty · Mar 25, 2013 at 04:43 AM
no, we cannot pause the particular object in the scene rather we can stop that functionality if you use the time scale is 0 the total scene will be pause.
Your answer
Follow this Question
Related Questions
How would I make a route that shows where player moves beforehand? 0 Answers
Changing material orientation dependant on mouse location? 0 Answers
Finish One Combo 1 Answer
Collision with renderer.enabled? 0 Answers
endless 2D background in Javascript 0 Answers