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 markfrancombe · Jun 02, 2016 at 10:43 PM · collisionrigidbodycontrollercolliders

Parented Game object with collider not colliding

Hi, I have a 1st person player, using character controller. I have some walls. The Player colliders and wont go through the walls. GREAT SO FAR! The player can "pick up" and electric guitar. This is an game object with a box collider on it. Hovering over it picks it up, which means its position is placed right in front of the view, and is parented to the camera, so that it moves with you.

HOWEVER! When I move towards a wall, the guitar will go through the wall, the player will stop, but as you move around the guitar will intersect the wall.

How can I stop this from happening?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Static-Dynamo · Jun 02, 2016 at 11:07 PM

When something is parented it pulls all of it's locational data from the parent object. This will override things like collisions.

One way to fix your issue would be to add an additional collider to the parent object that is at the location of the guitar object. Then it will not let the guitar pass through the wall.

There are multiple ways to tackle this. The simplest way might be to not have the guitar become a child of the character controller at all, instead have it's transform position constantly updating to be at a position of an empty or invisible game object.

Another way to do it would be to create a collider that is the same shape, size, and orientation of the guitar's collider on the parent object when the guitar get's picked up.

Comment
Add comment · Show 4 · 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 markfrancombe · Jun 03, 2016 at 07:11 AM 0
Share

@Static Dynamo Thanks for that, first sentence explains a lot!

Im drawn to your first suggestion to move the guitar by its transform position, rather than parenting.

The second suggestion I'm not sure about. when you say make an additional collider, in the position of the guitar WHEN it's parented. Firstly, if I parent that additional collider won't that have the same issue, as in, not work as its taking its info from its parent, or does that only happen when you parent during gameplay? I have tested this of course, by parenting the guitar from start, (this was another solution I was considering, as in enabling and disabling a hidden guitar on pickup, but I rejected this cos it still didn't collide.

$$anonymous$$ark

avatar image Static-Dynamo markfrancombe · Jun 03, 2016 at 07:16 AM 0
Share

So you wouldn't make a new collider and parent it, you would make a new collider as a part of the parent. Not part of the child. You wouldn't parent that additional collider you would just attach it to the parent.

avatar image markfrancombe Static-Dynamo · Jun 03, 2016 at 08:12 AM 0
Share

By attached, you mean what? Because it would have to be parented in some way would it not? I will still have to disable it at game start and enable it when needed, or else its going to collide the whole time, even when NO guitar is picked up.

... oh but wait.. do you mean I have the box collider (for surrounding the guitar) on the same component as the char controller...(which acts as the collider for the player).. Yes.. well unfortunately I can´t do that. The camera has a mouselook type code on it, and so in order for the guitar to appear to be "fixed" in the camera view it has to be parented to the camera parent. which makes it a child of the char controller. Thats not a problem with your first suggestion, as I can easily have the guitar follow a dummy GO that IS parented to the camera.

So I think Ill start with that solution... slightly concerned if thats a system drag at all... I dont know about that stuff. but Ill test and see if its robust and smooth.

Thanks for you help @Static Dynamo

Show more comments
avatar image
1

Answer by markfrancombe · Jun 03, 2016 at 09:49 AM

@Static Dynamo said

You can actually create a collider that has its center is offset from the position of the object that you have the collider attached to.

Yes but the character controller doesnt ACTUALLY rotate itself so when the camera rortaes AROUND the char controller, the child object will stay where it was.

This will mimic the behavior of a child object that is offset from the parent without needing to do any child/parent relationship. So it can still work even if you have a mouselook script moving the camera around, because the collider attached to the camera is offset from the camera's transform position.

And that collider WILL rotate around the char controller WITH the camera. So still not convinced by this, (or not getting it) Does this pic (whiteboard equivalent) help?

alt text

Maybe not?

:)

Mark


guitar.png (415.3 kB)
Comment
Add comment · 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 Static-Dynamo · Jun 03, 2016 at 05:32 PM 0
Share

Aha! You are 100% correct. It was late and I did not read your last response as carefully as I should have. If your camera is a child of the character controller this won't work. You've got it.

avatar image markfrancombe Static-Dynamo · Jun 03, 2016 at 09:41 PM 0
Share

Im still holding out for your very first suggestion... I hope that will work...

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

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

Related Questions

player going through walls even though it has colliders and rigidbodies 0 Answers

why my object pass through 0 Answers

Why is my Character's BoxCollider getting stuck in between two wall BoxColliders? 0 Answers

Opponents jerking while using SWS -1 Answers

Why does the player hover over the ground instead of touching it? Why doesn't it always jump when I press space? 2 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