• 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 shock2provide · Jul 30, 2014 at 05:46 PM · cameraparentoffset

Not being able to move an object who's parent is the main camera

Hey

Here is the script that doesn't work as intended:

 #pragma strict
 
 var inventoryIcon:Texture2D;//this is what will be displayed in the On Screen GUI.
 var isStackable=false;//If this is true it will be stacked in the inv.
 var maxStack=9;//each stack can be this big.
 
 public var EquipedWeaponOffset:Vector3;
 
 function BeDropped(){//This will drop the item wherever the player is.
     //since the player has the item parented to him, and at his position (locally) we are going to just 
     //drop the item where it already is
     rigidbody.constraints = RigidbodyConstraints.None; //Removing the x/y/z position constraints
     transform.localPosition=Vector3(0,0.1,0.07); //Moving position to infront of the player
     transform.collider.isTrigger=false;//reactive its collider.
     transform.renderer.enabled=true;//allow it to be seen again.
     transform.parent=null;//give it no parent.
 }
 
 function BeEquiped()    {
     transform.parent = Camera.main.transform;
     transform.localPosition=EquipedWeaponOffset;
     transform.renderer.enabled=true;
 }


Any help is greatly appreciated. Regards Marc

EDIT: I have tried changing transform.position = EquipedWeaponOffset. No change in result.

EDIT2: I have also tried creating an empty gameobject as a chield of the camera and using this gameobject as a parent for my BeEquiped function. That did also not work.

Comment
Add comment · Show 9
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 $$anonymous$$ · Jul 30, 2014 at 06:54 PM 0
Share

Hey, what if you use just position ins$$anonymous$$d of localPosition?

avatar image shock2provide · Jul 30, 2014 at 07:09 PM 0
Share

@ZyTr0n this didn't change anything.

avatar image Arcadewiz · Jul 31, 2014 at 01:18 PM 0
Share

Is it possible, to achieve your objective by making camera a child ins$$anonymous$$d of a parent? Why are you trying to parent the camera in the first place ?

avatar image shock2provide · Jul 31, 2014 at 01:22 PM 0
Share

@Arcadewiz I want to use the Camera as the parent, so if an Equip Item gets selected the item gets moved in front of the camera. Then the item (3d object) should move with the player/camera (also if you look up and down).

avatar image QC_Scott · Jul 31, 2014 at 01:28 PM 0
Share

Trying using a 1st person character controller and then putting the equip items in front of that.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

RenderTexture and OnMouseEnter offset 0 Answers

C# - Offset In-Air Camera from Current Object Position 1 Answer

Move linked camera after parent walked a distance 1 Answer

Howto set main.camera as a parent when main.camera itself is a child of a prefab 1 Answer

FPS collider center offsets camera pivot? 0 Answers


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