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 /
avatar image
-1
Question by MechWarrior117 · Jun 03, 2011 at 05:55 PM · collisionrigidbodycollidertrigger

Collision not working at all [ABANDONED]

Ok, I'm getting a little pissed off because I can not for the life of me get this to work! I have a simple box (WITH COLLIDER) that is supposed to move towards a sphere (AGAIN WITH COLLIDER). Neither of them are triggers.

When the box hits the sphere, its supposed to print out "HIT!" in the debug log. Instead, it doesn't do anything but shake around. (I know its supposed to shake, but its not registering a collision at all).

I have looked at every tutorial I can find with no luck. here is the code for the box:

 var target1 : Transform;

var target2 : Transform; var which = true;

function Update () {

 if (which == true){
     transform.LookAt(target1);
 }else{
     transform.LookAt(target2);
 }    
 transform.Translate(Vector3.forward * Time.deltaTime * 3);
 

}

function OnCollisionEnter(collisionInfo : Collision){ //which = false; Debug.Log("HIT!"); }

Any Ideas? I don't want to use Rigid Bodies since neither the box nor the sphere are supposed to be physics objects.

thankyou.

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

4 Replies

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

Answer by Eric5h5 · Jun 03, 2011 at 05:59 PM

You have to use rigidbodies if you want collisions to work. See the chart on the bottom of this page.

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 MechWarrior117 · Jun 03, 2011 at 06:00 PM 0
Share

I know you can do it without using rigid bodies. I just want the computer to see that two objects are touching each other. I don't want them to bounce off eachother or anything like that

avatar image Eric5h5 · Jun 03, 2011 at 06:08 PM 2
Share

@$$anonymous$$echWarrior117: you can't do it without using rigidbodies. But it sounds like you want triggers, not collisions.

avatar image
3

Answer by Tasarran · Jun 03, 2011 at 07:46 PM

You can make the objects RigidBodies, then toggle the Is Kinematic on.

This means that they will have access to the RigidBody functionality, but they won't be affected by physics, just controlled by scripting.

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
2

Answer by Meltdown · Jun 03, 2011 at 06:24 PM

If you don't want to use rigidbodies you'll need to to mark your objects as triggers.

Then use OnTriggerEnter to do your collision detection.

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 DaveA · Jun 03, 2011 at 07:19 PM 0
Share

If I'm not mistaken, setting them as 'is trigger' will also disable the physics of the collision (it won't stop or bounce), but you'll get the OnTriggerEnter event so you can handle that yourself.

avatar image Meltdown · Jun 03, 2011 at 08:41 PM 0
Share

As he states in a comment below Eric's answer, he doesn't want anything bouncing off anything, her just wants a collision intersection to register :p

avatar image MechWarrior117 · Jun 03, 2011 at 09:04 PM 0
Share

ok, so I made both colliders (sphere and Cube) triggers and used OnTriggerEnter, but I'm still not getting the Debug $$anonymous$$essage! Thank you all so much for your help :) but I am still having trouble.

avatar image Meltdown · Jun 14, 2011 at 06:10 PM 0
Share

$$anonymous$$ech, did you ever resolve this? If not I'll make you a test project to show you how its done. You're definately missing something.

avatar image
1

Answer by youmu42 · Jun 03, 2011 at 07:24 PM

You could have two colliders per object: One set for the physics(regular) and one for the collision detection(trigger). This would also give you the flexibility to change the hit detection for difficulty adjustment without getting different physics as a result.

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

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Objects placed manually collide, but don't if instantiated? 1 Answer

Collisions - bounce of walls but not from characters (while still reacting with them) 0 Answers

Can't add Rigidbody component because collision prevents it 2 Answers

Collider2D/RigidBody2D not working 1 Answer

Possible to stop collider from "popping" through plane when re-centering? 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