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 Robby-rEINEWALD · May 16, 2015 at 03:52 PM · collideristrigger

Can i make istrigger true just for spesific object ?

I want to make istrigger is true just for my ball, so my ball can go through line and my player can not pass it, it is like net in tennis. This is the screenshot alt text

hockey.jpg (57.6 kB)
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
1
Best Answer

Answer by matmel · May 17, 2015 at 07:18 PM

Hey there! Are you looking for something like this:

 GameObject.Find ("Ball").GetComponent<Collider> ().isTrigger = true;
Comment
Add comment · Show 5 · 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 Robby-rEINEWALD · May 20, 2015 at 06:36 AM 0
Share

more or less, but it will make isTrigger = true for all objects. I just pull y axis of net, so the ball can pass through the net and player can not.

avatar image matmel · May 23, 2015 at 07:15 AM 0
Share

I'm a little unsure of what you want here, but if you want to make a tennis net, then the ball and the player should not be able to pass through it. Are you making a 2D topdown tennis game? In that case I would use the code i gave you here for a while ago. The code will only make the ball collider a trigger. You will need the ball collider to collide with the bat again on the other side, so heres what im thinking:

 float dist = Vector3.Distance(net.transform.position, ball.transform.position);
 
 if(dist < 5f) //Dunno if 5 fits
 {
 GameObject.Find ("Ball").GetComponent<Collider> ().isTrigger = true;
 }
 if(dist > 5f) //Dunno if 5 fits
 {
 GameObject.Find ("Ball").GetComponent<Collider> ().isTrigger = false;
 }

Sorry for long delayed answers

avatar image Robby-rEINEWALD · May 24, 2015 at 07:01 AM 0
Share

I have edited the question, that's all I do to solve my problem, But I'm still thinking. Is there anyway to make the ball pass wall, but the others can't do it.

avatar image matmel · May 24, 2015 at 09:59 AM 0
Share

I think the code i posted earlier will solve your problem. I've also found another possibility, take a look at ignore collision: http://docs.unity3d.com/ScriptReference/Physics.IgnoreCollision.html

avatar image Robby-rEINEWALD · May 25, 2015 at 11:13 AM 0
Share

I think it will work, thanks but I prefer without script.

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

19 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

Related Questions

Is Triggered Collider Issue 1 Answer

A Collider problem. 1 Answer

Make object stay on the Terrain, while the isTrigger is checked 0 Answers

Rigidbody bounce or character controller istrigger issues 0 Answers

Possible Unity BUG? Or am i missing something 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