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 SynGT · Mar 18, 2016 at 02:05 AM · rigidbody2daddforcecollider 2d

RigidBody only moves when I remove Collider

I'm trying to create Flappy Bird as a tool to learn Unity & essentially I've added this script to the "pipes". When I remove the Collider they work perfectly fine, but obviously I need the collider for them to function properly. When I add the collider they just sit there & bump into each other.

Any ideas?

 #pragma strict
 
 public var speed : int;
 
 function Start () {
 
 var newSpeed : Vector2;
     newSpeed.x = speed;
     newSpeed.y = 0;
 
     GetComponent.<Rigidbody2D>().AddForce(newSpeed);
 
 }
 
Comment
Add comment
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

2 Replies

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

Answer by Magius96 · Mar 18, 2016 at 04:11 AM

Ok, so you need the colliders to see when the player hits them, but you don't want them to hit each other. This is actually simple. Click the checkbox on your pipe colliders to make them triggers. Then in the player, look for trigger events.

Now, this will have the unfortunate side effect of the player not actually colliding with the pipes, but if this is to be like the original flappy bird, that is fine since as soon as the collision occurs the player is dead anyways.

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 SynGT · Mar 18, 2016 at 12:09 PM 0
Share

Ok. I understand what you're going for; however, my idea for the game I was going for was going to be to have the collision knock the player off the screen, which would result in the game over.

avatar image Magius96 SynGT · Mar 18, 2016 at 04:21 PM 0
Share

When you detect the trigger, change the velocity of the player appropriately. So if the player was moving right (1, 0, 1) and you want them to fall down off the screen, then you might set the velocity to (0, -1, 0).

Oh, and your probaby better off using

 void OnTriggerEnter2D(Collider2D other)

Assu$$anonymous$$g your game is 2D, otherwise you'll want

 void OnTriggerEnter(Collider other)
avatar image
0

Answer by SynGT · Mar 22, 2016 at 03:45 AM

I just went a different way with this. Your OnTrigger helped, but it didn't quite answer the question.

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

50 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

Related Questions

RigidBody2D velocity randomly drops to zero 1 Answer

Enemy AI Script Error 1 Answer

AddForce rigidbody 2d not moving object 2 Answers

how to fire my player out of a Cannon? 0 Answers

Rigidbody2D AddForce Impulse not working on X axis 5 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