• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by DrunkGamer · Aug 14, 2013 at 09:59 PM · rotationpositionobjectfreezeblinking

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.

Comment

People who like this

0 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

  • Sort: 
avatar image

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();
     }
 
Comment

People who like this

0 Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DrunkGamer · Aug 14, 2013 at 10:08 PM 0
Share

Thx for the quick answer, I'm going to check out if it works.

avatar image zombience · Aug 14, 2013 at 10:57 PM 0
Share

no problem. in my example, I'm assuming 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.

avatar image

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

Comment

People who like this

0 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DrunkGamer · Aug 14, 2013 at 10:19 PM 0
Share

Thx for your answer too! I'm going to check it out also.

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Freeze camera 1 Answer

Freeze rigidbody position without affecting rotation - please help! 1 Answer

How to freeze the rotation or the position on the camera transform? 1 Answer

how to set rotation / position of an object on trigger? 2 Answers

Add force at position with respect to rotation 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges