*
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class StopForce : MonoBehaviour {
|
||||
public bool apply = false;
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
if (apply) {
|
||||
//float f = rigidbody.mass * (rigidbody.velocity.magnitude / Time.fixedDeltaTime);
|
||||
//rigidbody.AddForce(-rigidbody.velocity.normalized * f);
|
||||
float f = (rigidbody.velocity.sqrMagnitude * rigidbody.mass) * 0.5f;
|
||||
rigidbody.AddForce(-rigidbody.velocity.normalized * f);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user