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 Bolt · Jul 23, 2013 at 04:56 PM · rigidbodyvelocityaddforceslowslowmotion

slow addforce

in my scene I have a ball that is thrown, so I added a addforce want you to slow down when it touches the ground its strength to a stop. I tried with rigidbody.sleep () but I do not like it stops abruptly. How can I do?

 public var speed : float;
 private var bar : float = 25;
 static  var myInt = 0;
 public var sfera : GameObject;
 public var coord : Vector3 = new Vector3 (0,5,5);
 public var forza : ForceMode;
 public var max : int = 100;
 public var min : int = 0; 
 static var count : int = 0;
 static var click : boolean = false;
 
 
 
 function Start(){
 
 
 }
 
 
 function Update(){
 
 
 
    if(/*Input.GetMouseButton(0) && count == 0*/ click == true && count == 0){
    
   
     
     speed += bar * Time.deltaTime;
     
     myInt = Mathf.FloorToInt(speed);
     
     
     
     if(myInt >= max){
     
     myInt = 100;
     
     }
     
     
     print(myInt);
     }
    
     if(Input.GetMouseButtonUp(0)){
   
      click = false;
      sfera.rigidbody.AddForce((coord*myInt)/2,forza);
      
      myInt = min;
      
      //count += 1;
   }
   gameObject.Find("Main Camera").SendMessage("Follow");
    
 }
 
 function OnMouseDown(){
 
   // if(click == false){
     
      click = true;
      
    //}
    }
    
 function OnMouseUp(){
 
     count += 1;
     lerp.pp = true;
     
 }
 
 function OnCollisionEnter(pavimento:Collision)
 
 {
 
 if(pavimento.gameObject.tag == "pavimento")
 
 {
     
     coord = new Vector3 (0,0.01,0.01);
     }
 
 
 }
Comment
Add comment · Show 1
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 Benproductions1 · Jul 24, 2013 at 04:24 AM 0
Share

'Please remove unnecessary whitespace. The code is unreadable.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by robertbu · Jul 24, 2013 at 04:36 AM

If I understand your question correctly, the easiest thing to do would be to setup the physic materials of both the ball and the floor so that the ball behaves like you want:

http://docs.unity3d.com/Documentation/Components/class-PhysicMaterial.html

The physic material is set in the collider of the objects. You can get a standard set of physic materials to start by going to the 'Assets' menu and selecting Import Package/Physic Materials.

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

16 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

Related Questions

Why is velocity checking intensive? 0 Answers

Rigidbody Addforce cancels out Rigidbody velocity..maybe? 0 Answers

Gravitational pull without losing speed 1 Answer

Rigidbody y velocity is stuck on 0, gravity is not turned off. 2 Answers

Why does writing to rigidbody.velocity after AddForce stop my rigidbody moving? 4 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