- Home /
How to freeze character and other things and execute other scripts
Hi folks!
I'm on a 2,5d platformer game with some edit-during-play features.
For the moment I implemented a this:
I can move my character aroud the level with the classic controls (wasd, arrows etc..) and when I hit a key I've the ability to place some objects to the level, moving them with the same controls of the character.
What I want is stop/freeze the character during the level editing, and maybe freeze other things on the level (enemies...rotating objects..)
Any suggest?
Tnx :)
Answer by IgnoranceIsBliss · Apr 16, 2012 at 10:46 PM
We probably need more detail.
Normally, objects in Unity stay perfectly still unless you actually ask them to move.
Normally all you need to do to stop something moving is to disable the components and behaviours that are MAKING them move.
If you are using physics, turn off their RigidBody, CharacterMotor or CharacterController scripts. That will stop them falling.
Then also turn off any other behaviours you've created that control movement.
For example (in C#, assuming this script is ON the object you want to stop...)
CharacterMotor Mtr = GetComponent<CharacterMotor>();
Mtr.enabled = false;
Your answer