- Home /
Freeze object's position and rotation
Being more specific, i want to know how can i make an object (more specifically an statue model) freeze at it's current position and rotation when seen. I'm making an small project which is heavily based on the weeping angels and a little bit on slender (But it isn't the typical "Hurr durr get tah noutes bifor slender kills yah") and i need to have a script which freeze the angel (in it's actual animation, if possible) when the player sees it and unfreezes it when it's out of the camera's view.
Extra: Also I'm thinking about adding a "blinking system" as i like to call it, in which your character needs to blink every X seconds (Like in SCP containment breach) but from all the scripts i wrote, every single one of them failed.
Answer by zombience · Aug 14, 2013 at 10:06 PM
you can use the isVisible property of any renderer to check whether it is in view of the camera.
http://docs.unity3d.com/Documentation/ScriptReference/Renderer-isVisible.
StatueScript statue;
if (statue.gameObject.renderer.isVisible)
{
statue.FreezeMovement();
}
Thx for the quick answer, I'm going to check out if it works.
no problem. in my example, I'm assu$$anonymous$$g you've made your own script to control the statues, and that you have some public method that can stop the movement portion of that script.
whether you set the rigidbody to kinematic, flip a bool so that transform position no longer gets updated, or whatever, that part is dependent on your script. I didn't attempt to write that here because it depends entirely on your coding.
Answer by gogu23 · Aug 14, 2013 at 10:10 PM
Hallo :)
Well you can make an Emtygameobject and add a square Collider to it .. its and invisible collider.
And then you can make a script with IF statements like
function OnTriggerEnter (other : Collider)
{
// Check for collsion
if(other.gameObject.tag == "Gametagofyourobject")
{
Debug.Log("you did just collide and need to freese");
}
And then in the if statement ..
you can look in the unity API after the transform class and see your options and then make a math.clamp ... i am sure you can figure something out that way
Hope this helps just a little
Thx for your answer too! I'm going to check it out also.
Your answer
Follow this Question
Related Questions
Return object to position 3 Answers
Add force at position with respect to rotation 1 Answer
set child object position when playing the animation 0 Answers
Move object A towards object B 2 Answers
Make object appear within camera view 0 Answers