• 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 imnickb · Apr 05, 2013 at 06:53 PM · physicsrigidbodykinematiccoiniskinematic

How can I make my coins move without knocking my player around?

I have coins that I'm spawning and making fly from left to right so the player can jump up and collect them. When they collide I just want to destroy the coin and increment the coinCount. The problem is that when the coin hits the player, it knocks him around a little bit. I've already locked all of the axis and rotation I can on the player but I'd like to make the coins have no impact on the player at all. Reducing the coin mass makes them not move across the screen properly. Is there a better way to move the coins or should I be using isKinematic? I read that moving an object without a rigidbody is bad for performance which is why I did it this way.

 var objectSpeed : float = 100;
 
 function Start ()
 {
 
 }
 
 function Update () {
         rigidbody.AddRelativeForce(objectSpeed/100*-1, 0, 0);
 }
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
1
Best Answer

Answer by Gurc · Apr 05, 2013 at 07:04 PM

I think you should make mass 0, and add velocity, not force like:

And you should do that in start. If you add it in each loop that would be another problem.

(I wrote in c# you should translate it to java.)

  function Start ()
 {
 Vector3 Direction=new Vector3(x,y,z);
 Direction.normalize();
 Direction*=objectSpeed;
 rigidbody.velocity+=Direction;
 }
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 imnickb · Apr 05, 2013 at 10:04 PM 0
Share

Turning them into triggers didn't make much of a difference, I'm guessing because I was destroying them after the collision anyway so they didn't have time to bounce off of anything. I made them triggers anyway, since I think that's probably more appropriate. $$anonymous$$oving with velocity fixed the issue.

 function Start ()
 {
     rigidbody.velocity = Vector3(-2,0,0);
 }
avatar image
3

Answer by Dracorat · Apr 05, 2013 at 07:09 PM

You need to turn the coins in to a trigger using the Is Trigger property. This turns off their simulation of bounce and rotation during a collision and moves collision events to the trigger functions instead of collision functions. (But those functions are still only called when the collision occurs.)

http://docs.unity3d.com/Documentation//ScriptReference/Collider-isTrigger.html

http://docs.unity3d.com/Documentation//ScriptReference/Collider.OnTriggerEnter.html

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

12 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

Related Questions

Child Rigid Body collision problem 2 Answers

Switch off Kinematic for a Rigidbody in response to an explosion or impact? 1 Answer

Preventing objects from intersecting with minimal physics 3 Answers

Realistic collisions with a kinematic rigidbody? 1 Answer

Moving and SweepTesting a kinematic Rigidbody multiple times within a single FixedUpdate() call 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