Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by JesseSomerville · Feb 17, 2014 at 03:24 PM · objectscalepickupwtf

Object changes shape randomly.

When I pick up an object it slightly changes size, and when I drop it, it greatly changes size. It's directional. It will expand about 1 unit away from the player and it will be slightly thinner. I have no clue whats happening.

 #pragma strict
 
 var Distance : float;
 var MaxDistance : float = 4.0;
 var Hand : GameObject;
 var Item : GameObject;
 var TheSystem : Transform;
 var Weapon01 : GameObject;
 var HoldingItem = false;
 
 function Start () {
     Hand = GameObject.Find("Hand");
     Item = GameObject.Find("Cube");
     Weapon01 = GameObject.Find("Weapon01");
 }
 
 function Update () {
     var hit : RaycastHit;  
      if (Physics.Raycast (TheSystem.transform.position, TheSystem.transform.TransformDirection(Vector3.forward), hit))  
      {  
          Distance = hit.distance;  
            if (HoldingItem == false)
            {
                var ItemScale = Item.renderer.bounds.size;
            }    
            if (Distance < MaxDistance && Input.GetMouseButtonDown(0) && HoldingItem == false && hit.collider.gameObject.tag == "PickUpable")  
            {  
                Destroy(Weapon01);
                Item.rigidbody.useGravity = false;
                Item.rigidbody.isKinematic = true;
              Item = hit.collider.gameObject;
              Item.transform.parent = Hand.transform;
              Item.transform.position = Hand.transform.position;
              HoldingItem = true;    
              var Wait = Time.time + 10;
          }
          
      }
      if (HoldingItem && Input.GetMouseButtonDown(0) && Wait <= Time.time)
      {
          Item.transform.parent = null;
          Item.rigidbody.useGravity = true;
          Item.rigidbody.isKinematic = false;
          HoldingItem = false;
      }
      if (HoldingItem)
      {
          Item.renderer.bounds.size = ItemScale;
          print(ItemScale);
      }             
 }
Comment
Add comment · Show 2
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 JesseSomerville · Feb 19, 2014 at 01:34 PM 0
Share

It was a problem with parenting and un-parenting the object.

avatar image Ed unity · Feb 19, 2014 at 07:32 PM 0
Share

You should post the answer to the problem that you were having so that others may use it for reference if they have a similar issue. That would be greatly appreciated by others I'm sure.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by JesseSomerville · Feb 23, 2014 at 04:56 PM

The problem was A glitch with parenting and un-parenting the object. I fixed it by just having the object follow my hand object instead.

Comment
Add comment · 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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

19 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 avatar image avatar image

Related Questions

Is there a way to disable Unity changing the texture scaling when using multiple materials 0 Answers

Making objects look further away in ortho cam 1 Answer

How do i set a "object.max" scale ex.:: X axis ? 1 Answer

Respawn pick up objects when scene is loaded? 1 Answer

Object scale 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