Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

slow addforce

$
0
0
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); } }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>