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 stiltskin · Jan 08, 2011 at 08:51 PM · collisioncollidertriggerscale

Scaling a collider to set an event

Im trying to create a visual effect where a bunch of cubes play an animation when a growing spherical trigger engulfs them.

Let me explain further...

various scattered cubes are laid out. they all have a script that has collision detection on them that tells them to play an animation once the collision happens.

function OnCollisionEnter(Collision : Collision){
 if(Collision.gameObject.name == "BlockBuilder"){
  Debug.Log("Entered Trigger");
 }
}

Then there is a sphere collider that has an animation that scales its radius to a huge value over 2 secs.

In theory, what should happen is once a cube is inside the sphere because it has scaled over it, the script should run - but it's not. The only way I can get a detection to happen is if I put rigid bodies on each but then the sphere just pushes the cubes along.

I've tried using a trigger, but to do so I need to place the script on the sphere object and then it will require a giant list of pre-defined objects to check to see which cubes to affect, which I don't want - I want it to be dynamic.

any ideas on how to do this? the easiest way I can think of is somehow making the rigid body not affect anything, is that even possible?

thanx!

Thank you so much for helping out! so here is the script that works:

function OnTriggerEnter(Col : Collider)
{
    if(Col.gameObject.name == "BlockBuilder")
    {
        Debug.Log("Entered Trigger");
    }
}

What I needed to do was make it a trigger so that it doesnt push anything around, but still leaving the rigid body there. It works like a charm now! Thank you so much for the help!

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

Answer by Jesse Anders · Jan 08, 2011 at 09:11 PM

Does the code you posted actually compile? (I haven't tried it, but I'd expect the variable name 'Collision' to generate an error. I don't use UnityScript though, so maybe there's something going on there that I'm not aware of.)

Regarding the problem you describe, I'd expect that if you made the sphere collider a trigger and then used OnTriggerEnter() rather than OnCollisionEnter(), it would work. Have you tried that?

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 stiltskin · Jan 08, 2011 at 11:31 PM 0
Share

yeah, it compiles and works - as long as I turn on rigid bodies everywhere. but like I said, the problem that I get is that the big sphere ends up just pushing the cubes around (even though the collision happens anyway). Basically you end up seeing the event happen but at the same time they get pushed around.

I have tried with a trigger but could not get it to work. $$anonymous$$aybe I'm using the formatting badly. I have no clue. The only reason why I have been focusing on collision though is because I assumed that the trigger itself is the one that supposed to have the OnTriggerEnter function on it.

avatar image Jesse Anders · Jan 08, 2011 at 11:51 PM 0
Share

I think both objects involved in a 'trigger' collision receive an OnTriggerEnter() message (you can check the docs to make sure). In any case, although I haven't tried it, I think making the sphere a trigger should work; if it's not working, you likely have something set up wrong. (Also, I'm a little surprised that UnityScript will let you give a variable the same name as a type, but like I said, I don't use US so I might be missing something there.)

avatar image stiltskin · Jan 09, 2011 at 12:03 AM 0
Share

Ok, this is awesome. I got it working with the trigger. It looks like you still need the rigid body but once you make it a trigger it doesnt move anything around anymore. Thanx!

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

Triggering platform animation on colliding with Button 0 Answers

change the scale of collider to trigger "OnTriggerEnter",Change the scale of collider to trigger "OnTriggerEnter" 0 Answers

Prevent shooting when gun is inside wall 1 Answer

Collision between objects? 2 Answers

How to get collision point when using onTriggerEnter 5 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