• 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.

Show more comments

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

Trigger Collider is Triggering? 0 Answers

Trigger enter and directly Exit 0 Answers

How to make an object move to the direction in which the user faces using vr gaze interaction? 1 Answer

Triggers colliding with triggers 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