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 haico1992 · Oct 05, 2012 at 07:05 AM · collisioninstantiateposition

Collider not triggered when change posision

I was doing the 1st Lab of Walker's Boys training session.

What I am trying to do is randomize 3 cubes in front of camera without collided with other by OnTrigger/OnCollision functions

The problem is the event does not trigger if those cubes didn't move after instantiate or move(It's work just fine when a cube fall on another cube)

Is that how it support to be, or I missed something? Here the code:

 function move(){
 var position :Vector3;            
         position.z= 9;
         position.x= Random.Range(-0.7,1.7);
         position.y= Random.Range(13.2,15.2);        
         this.transform.position=position; 
 }
 function OnCollisionStay(other:Collision){
     Debug.Log("Triggered");
     this.move();
 }

 
Comment
Add comment · Show 1
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 haico1992 · Oct 05, 2012 at 01:19 PM 0
Share

Please give me some direction, I dont have any idea where to start looking for.

1 Reply

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

Answer by ThePunisher · Oct 05, 2012 at 04:50 PM

Check out the doc:

http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnCollisionStay.html?from=Collision

It says you might want to take out the "other:Collision" parameter from the OnCollisionStay method unless you are actually using it.

Now to address the actual problem. As I understand, if your cubes are able to trigger each others colliders (which makes sense), but something else is not then that GameObject is missing a collider and a rigidbody component.

Also, know that the OnCollisionStay is called for every frame that the objects are colliding, if you only want to know when the initial collision happens then you might want to use OnCollisionEnter (or OnTriggerEnter)

http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnCollisionEnter.html?from=Collision

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 haico1992 · Oct 05, 2012 at 06:18 PM 0
Share

Thanks, it's work after I added rigidbody (without gravity and freeze everything). $$anonymous$$y cubes still have the collider since the start, but maybe it's just not work in this situation.

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

10 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

Related Questions

Unity 2D - MoveTowards position not updating, not recgonizing new position 1 Answer

GameObject change Position after game started 1 Answer

how to I zero out a parented child's position in X,Y,Z on collision? 1 Answer

Keep instantiated GameObject's position while parenting it to another GameObject 3 Answers

GameObject Instantiated in Wrong Position 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