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 /
  • Help Room /
avatar image
0
Question by $$anonymous$$ · Sep 02, 2016 at 08:10 AM · collidertriggervector3

Moving a child object to collide with wall.

Good morning all,

Sorry for the long post.

I have a game where I am generating walls and platforms up the Y axis and I need to make the platforms move left and right randomly. In the image below the green platform is a child object of the frame. I can make the green platform move but it is not colliding with the walls even though I have them collidable in the Physics settings.

alt text

My code for the Platforms to spawn and position randomly between the walls is below. (I have two copies of my project, one at work that I work on during lunch and the main one at home) In the code I have OnTriggerEnter for when the platform collides with the wall but it never gives out a value even though I make it debug.log it.

Please could you show me where I'm going wrong. Thanks in advanced

 public class MovingPlatform : MonoBehaviour
 {
 
     private float platformMin = -6.5f;
     private float platformMax = 6.5f;
 
     void Start()
     {
         RadomizePlatforms();
     }
 
     public void RadomizePlatforms()
     {
         GameObject[] platforms = GameObject.FindGameObjectsWithTag("PlatformFrame");
 
         foreach (GameObject platform in platforms)
         {
             Vector3 pos = platform.transform.position;
             pos.x = Random.Range(platformMin, platformMax);
             platform.transform.position = pos;
         }
     }
     void OnColliderEnter (Collider other)
     {
        //tell me what the platform triggered
         Debug.Log("triggered: " + other.name);
     }
 }

platforms.png (91.6 kB)
Comment
Add comment · Show 3
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 doublemax · Sep 02, 2016 at 08:15 AM 0
Share

Try OnCollisionEnter ins$$anonymous$$d of OnColliderEnter.

avatar image $$anonymous$$ doublemax · Sep 02, 2016 at 08:20 AM 0
Share

Just tried that now, still nothing.

avatar image doublemax $$anonymous$$ · Sep 02, 2016 at 01:06 PM 0
Share

If you're using 2D physics, how about OnCollisionEnter2D ?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by $$anonymous$$ · Sep 02, 2016 at 08:26 AM

I think that it might be the layers that might be causing it but I'm not sure. The walls need to collide with the PlatformFrames and the Slider.

the platforms need to collide with the walls and the player(for now is default.)

alt text


platformslayer.png (11.5 kB)
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

90 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Creating a repel volume 0 Answers

Destroy instatiate object on trigger enter / collision,destroy instantiate prefab on trigger enter 0 Answers

Can’t keep the position 0 Answers

OnTriggerExit2D doesn't work when one of gameObject setActive false. 0 Answers

How to get the Collider other element Rigidbody? 0 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