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 wknight92 · May 14, 2012 at 04:59 PM · colliderontriggerentertriggers

why is one side of collider behaving different than the other

there's two game objects in question here. the ship(player) and the bouncer(wall that acts like a rubber barrier).

here's the script that makes the wall bounce the ship backwards.

 function OnTriggerEnter (other : Collider){
 if (other.name == "Ship"){
 Repel (other.gameObject);
 }

}

 function Repel (other : GameObject){
 var shipRepelSpot = other.transform.position + transform.TransformDirection(Vector3(-3, 0, 0));
 iTween.MoveTo(other, shipRepelSpot, 0.8);

}

basically what's happening is when the ship hits on side of this bouncing wall, it gets repelled properly. On the other side, however, the ship kinda squeezed through the wall in an awkward motion. I just want to know why would one side be behaving differently on the same object. I've checked the collider size. The ship/player is the trigger and has a rigidbody, the bouncing wall just has a collider.

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 Drakestar · May 14, 2012 at 05:17 PM 0
Share

Have you checked that shipRepelSpot is on the side of the rubber wall that you expect it to be on for both cases?

2 Replies

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

Answer by wknight92 · May 14, 2012 at 06:18 PM

 var shipRepelSpot = other.transform.position + transform.TransformDirection(Vector3(-3, 0, 0));

needed to be changed to

 var shipRepelSpot = other.transform.position + other.transform.TransformDirection(Vector3(-3, 0, 0));
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 Bunny83 · May 14, 2012 at 06:23 PM 0
Share

That doesn't make much sense ;) his script is on the wall, not on the ship and he wants the direction relative to the wall, not relative to the ship.

Btw, this:

 transform.TransformDirection(Vector3(-3, 0, 0));

is the same as

 transform.right * -3;

avatar image wknight92 · May 14, 2012 at 06:25 PM 0
Share

ah thanks!

avatar image
1

Answer by Berenger · May 14, 2012 at 05:25 PM

You're not using physic for the repulsion, only for the collision detection. The side isn't relevant then.

However, I guess that the two walls are facing the same direction / have the same rotation. Which means that transform.TransformDirection will point inside for one, outside for the other.

Rotate the incorrect wall of 180 on Y.

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 Bunny83 · May 14, 2012 at 06:25 PM 1
Share

The other way would be to make the direction vector configurable, so you can just remove the "-" in the inspector ;)

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

6 People are following this question.

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

Related Questions

Please HELP: ¿How can i made a drag and drop quiz?, i got some problems whit my scripts, like connecting the drag and drop function whit the buttons 0 Answers

show different textures when trigged entered thrice 2 Answers

How to pick up a game object using E 4 Answers

Can't figure out how to use multiple triggers in single scene 1 Answer

Kill Particles Entering 2D Trigger 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