Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Mister Giggles · Oct 16, 2015 at 03:49 PM · c#cameraraycastprefabhierarchy

Basic question about Unity functionality

Hi guys, I'm very new to coding and using unity.

Been following some tutorials to help myself learn, but have been running into issues with most of the tutorials being done in unity 4 (which through google I've been able to find the answers appropriately).

However, I just can't seem to understand what I'm doing wrong in this case.

I'll boil the very problem down to the basics.

1) I create a plane

2) I write a very basic script that interacts with the plane when I hover my mouse over it. Since it's for the tutorial, I also have a camera component on the script (as a public variable assignable in the inspector). The basic aspect of the script is a ray cast from the camera to my mouse pointer.

3) I apply the script to the plane.

4) I make the plane a prefab

5) I delete the original plane and re-add it to the hierarchy (not sure if necessary, just a habit I started doing)

6) I add the camera to the intended area attached to the script in the inspector.


Now, I test the functionality right here. Things are working properly, the script works.

So now I..

7) Duplicate the plane and align a few of them side by side.

  • These duplicates do not have the camera that was assigned to the script attached.

  • I cannot add the camera to the prefab itself

  • If I press the 'apply' button on the plane in the hierarchy, nothing changes for the prefab or for the rest of the planes

  • I can manually add the camera to all of the duplicates (and the script works for all of them while it runs)

  • ALSO OF NOTE: All other components follow over properly (e.g. the material color and transform position)

So I guess in the end my question comes down to how can I do this task in a more efficient manner?

If more information is necessary, I can provide it, but I believe I brought everything required.

Comment
Add comment · Show 1
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 meat5000 ♦ · Oct 16, 2015 at 05:14 PM 0
Share

Use GameObject.Find to look for the $$anonymous$$ain camera, or whatever camera it is you need in your script. This way the script will find its own reference.

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.

Follow this Question

Answers Answers and Comments

38 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 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

I can't get Physic.Raycast to work,My Physics.Raycast don't work 0 Answers

How can I make a third person camera collision script? 2 Answers

Any way to increase raycast range? 0 Answers

RayCast From Centre of Camera 1 Answer

Raycast hit not detection gameobject? 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