Hey all the Unity Pro´s
i have a little problem with my rigidbody´s velocity. look
I want to say, hey rigidbody of target, if you enter the trigger i want that you slow down your velocity at your local x axis. so i tryd this:
but its not working. The rigidbody slows down yes, but on its global x axis and this is the problem. Sees anyone my mistake?
Thank - Youuu
void OnTriggerEnter (Collider target) {
if (target.tag == "Car" || target.tag == "AI" || target.tag == "Destructable") {
if (NeedForceToBreak == true) {
if(target.attachedRigidbody.velocity.magnitude >= min_Velocity){
localVelocity = target.attachedRigidbody.transform.InverseTransformDirection(target.attachedRigidbody.velocity);
localVelocity.z = target.attachedRigidbody.velocity.z;
localVelocity.y = target.attachedRigidbody.velocity.y;
localVelocity.x = target.attachedRigidbody.velocity.x - StopVelocityForce;
target.attachedRigidbody.velocity = transform.TransformDirection (localVelocity);
StaticObject.SetActive (false);
ObjectWPhysics.SetActive (true);
Trigger.SetActive (true);