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 Unislash · Jan 15, 2011 at 06:32 PM · collidercharactercontrollerignorecollisionmissile

Missile colliding with Character Controller

Hello all,

I'm creating a missile via script attached to the first person controller. The only problem is that my missile collides with the character controller's collider before it moves anywhere. I've tried to use Physics.ignoreCollision() but it doesn't seem to work with the character controller.

function FireRocket () {
    var rocketClone : Rigidbody Instantiate(rocket, transform.position + Vector3 (0, 3, 0), transform.rotation);
    Physics.IgnoreCollision(rocketClone.collider, transform.root.GetComponent(CharacterController).collider);
...

I've used some printouts and determined that the missile is indeed colliding with the "CharacterController"

    Physics.IgnoreCollision(rocketClone.collider, transform.root.collider);

doesn't work either.

Any ideas? I could use layers, but I'd rather do it without them.

EDIT: I've done more testing, and my IgnoreCollision call points to the exact same object/collider that is colliding with my missile. I really don't understand why this isn't working.

Physics.IgnoreCollision(rocketClone.collider, transform.GetComponent(CharacterController).collider);

^^is the call that I'm using now, just to avoid any confusion. (they all should point to the same collider anyway)

Cheers,

Unislash

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

3 Replies

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

Answer by Unislash · Jan 16, 2011 at 05:47 PM

This turned out to be a very tricky problem. It turns out that my missile is a prefab, and has a core child for creating particles. The core for some reason had a box collider on it.

It appears that unity interprets any child collider as a collision with the parent too, so that was setting off the collision with the character controller--even though I turned the parent collider's collision with the character controller off.

I hope this helps someone, because it took me >4 hours to find this one!

Cheers,

Unislash

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

Answer by fireDude67 · Jan 15, 2011 at 06:49 PM

Instantiate() your missile farther away?

Comment
Add comment · Show 1 · 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 Unislash · Jan 16, 2011 at 10:05 AM 0
Share

Well clearly. But I don't want to have to deal with moving my missile generation based on who the player is.

avatar image
0

Answer by PrimeDerektive · Jan 15, 2011 at 07:02 PM

transform.root.collider would only work if this rocket was a child of the player object, and thats not something you want to do (the rocket would move around when the player moved around).

You'll have to cache a reference to the player in this script somehow, probably by making a

public var player : GameObject;

And dragging your player object from the scene to this exposed var in the inspector. Then use IgnoreCollision on the player's collider from there:

Physics.IgnoreCollision(rocketClone.collider, player.collider);
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 Unislash · Jan 16, 2011 at 10:07 AM 0
Share

Wouldn't transform.root.collider point to the root of the transform that the script is attached to? In this case, that is the player. In any case, this still doesn't work. See edit for updated information :-)

avatar image PrimeDerektive · Jan 16, 2011 at 01:56 PM 0
Share

Aw crap i'm sorry; misunderstood. I was thinking the ignore code was going in a script on the instantiated projectile for some reason.

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

Ignore Collision with Character Collider 2 Answers

OnColliderStay does not work 1 Answer

My Character controller is being push a little bit when i'm about the get the coins. How can i possibly detect collision and destroy the coins without actually getting affected by the colliding physics? 1 Answer

Rigidbody bounce or character controller istrigger issues 0 Answers

CharacterController doesn't work with collider 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