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 Unused Mass · Jun 03, 2013 at 05:07 PM · gameobjecttransformtranslate

Dont transform.translate if it will collide with another object

How would I transform.translate down, and stop if it will collide with another object. I've tried onTriggerEnter(), and it does not seem to work. (as in, it's still moving)

Comment
Add comment · Show 2
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 robertbu · Jun 03, 2013 at 05:25 PM 0
Share

Please post your code.

avatar image Unused Mass · Jun 03, 2013 at 06:42 PM 0
Share
 #pragma strict
 var a: Vector3;
 var isFalling : boolean;
 var fallingSpeed = 1;
 var can$$anonymous$$ove : boolean = true;
 
 function Start () {
     collider.isTrigger = true;
     collider.bounds.size.
 }
 
 function StartFall (speed : int) {
 
     isFalling = true; 
     fallingSpeed = speed;
 }
 
 function EndFall () {
     isFalling = false;
 }
 function Update () {
     if(can$$anonymous$$ove == true) {
         if(isFalling == true) {
             transform.Translate(Vector3.down * Time.deltaTime * fallingSpeed);
         }
     }
 }
 
 function OnTriggerEnter(otherObject: Collider){
     can$$anonymous$$ove = false;
 }
 
 function OnTriggerExit(otherObject : Collider) {
     can$$anonymous$$ove = true;
 }

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by fueldown · Jun 03, 2013 at 05:20 PM

check if either of the objects has rigidbody attached. OnTriggerEnter won't trigger if it doesn't.

Comment
Add comment · Show 16 · 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 Unused Mass · Jun 03, 2013 at 06:43 PM 0
Share

Neither has a rigidbody attached, I dont want any of them to be falling. I'm making a tetris-like game.

avatar image syclamoth · Jun 03, 2013 at 06:44 PM 0
Share

Don't use built-in physics, then. Use specialised, simple physics.

avatar image Unused Mass · Jun 03, 2013 at 06:54 PM 0
Share

Isnt that what I'm trying to do / doing?

$$anonymous$$aybe I should make a 3D array, ins$$anonymous$$d of detecting collisions.

avatar image syclamoth · Jun 03, 2013 at 07:00 PM 0
Share

OnTriggerEnter still uses built-in physics- I mean manually moving transforms around, and using whatever algorithm you like to manage potential collisions.

avatar image Unused Mass · Jun 03, 2013 at 07:40 PM 0
Share

Any suggestions for any algorithms?

Should I try the 3D array?

Show more comments

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

17 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

Related Questions

How to make an object go to pre-seted position in world 1 Answer

Moving a GameObject to a certain point in world space via script 1 Answer

How to make a projectile fly towards it's target 2 Answers

How to make a object translate alonge an other 2 Answers

Shaking GameObject Problem 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