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 MK7 · Apr 27, 2011 at 09:00 AM · raycastingchildaxistaghit

Get a raycast to hit only child objects to use axes

I have walls, floors, and ceilings of a level grouped under the name of Map5 which I have tagged Level. I have also made a rotation script that with the intention of rotating the whole level around the player. I want to use the walls axes for my rotation, which should have a sort of hinge effect.I have tagged the walls based on the direction they are facing (for example; left walls are tagged as Left) The problem I have is that the any wall the ray hits is counted as Level since they are all children of Map5. I need my ray to hit the children so I can use their axes but I don't know how. Please help?

Here is my current code If it helps at all...

var Player : Transform; var rotateAmount = 90; var controller : CharacterController; var Hit : RaycastHit;

function Start() { }

function FixedUpdate () {
//casts a ray from camera to point in world // If the controller is grounded and the ray hits an object; then you can Rotate walls if (controller.isGrounded) canRotate =true;
if(Input.GetMouseButtonDown(0)){ var ray = Camera.main.ScreenPointToRay (Input.mousePosition); if (Physics.Raycast (ray, Hit, 50)){ var Hitobject : GameObject = Hit.transform.gameObject; var pivot : Transform = Hitobject.transform; Debug.Log("hit"+ gameObject.name); if((Input.GetMouseButtonDown(0)) && (Hitobject.gameObject.tag == "Left")){ RotateObject(Player.position,pivot.forward, 90,1); } } } }

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

1 Reply

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

Answer by loopyllama · Apr 27, 2011 at 09:26 AM

If you are getting the entire level back then you have a collider attached to your entire level. You need to have colliders on your children in order to hit them.

by the way, if you rotate your entire world you lose out on static batching. something to consider.

Comment
Add comment · Show 3 · 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 MK7 · Apr 27, 2011 at 09:30 AM 0
Share

Well I do have a rigid body attached to it i'll take it off and see if it works.

avatar image loopyllama · Apr 27, 2011 at 10:39 AM 0
Share

the more information you provide, the easier it will be for us to solve

avatar image MK7 · Apr 27, 2011 at 06:28 PM 0
Share

Thank for your help! it turns out I did have a collider attached to the level. Taking it of did the trick

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

No one has followed this question yet.

Related Questions

How can I differentiate between colliding with an object or its child? 1 Answer

How can I get the tag of a child object? 1 Answer

Vehicle is vibrating on the edge of the ramp/surface when I get the normal of the surface 0 Answers

Freeze specific rotation axis of a child 2 Answers

Change raycasting 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