- Home /
How to get vector3.zero when using rigidbody.Addforce?
I'm adding force to the object and I wanted it to return a value when it stops. If I use rigidbody.velocity, I can get vector3.zero, but when I use rigidbody.Addforce I can't. Does anyone know why?
Thanks
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AddForce : $$anonymous$$onoBehaviour
{
public Rigidbody rigidbody;
public float upForce = 5.0f;
public float forwadForce = 10.0f;
// Update is called once per frame
void Update()
{
if(rigidbody.velocity == Vector3.zero)
{
Debug.Log("Velocity is Zero!");
Debug.Log(rigidbody.velocity);
}
}
public void AddForceAndVelocity()
{
rigidbody.AddForce(new Vector3(0, upForce * Time.deltaTime, forwadForce * Time.deltaTime), Force$$anonymous$$ode.Impulse);
}
@Captain_Pineapple If i use rigidbody.velocity, dont return Vector3.zero
Answer by Captain_Pineapple · Apr 12, 2020 at 08:39 AM
Have you tried larger values of force? Simple calculation: F= m* a (Force equals mass * accelleration)
So for example to cancel out the gravity you have to apply at least a force of mass*9.81 per fixed update with no Time.deltaTime
multiplication
Your answer
Follow this Question
Related Questions
How can i initiate an object in parabolic motion without using gravity using Rigidbody2D? 0 Answers
When stopping Rigidbody.velocity 1 frame stutter C# 0 Answers
How to limit only the Rigidbody.velocity from player input? 1 Answer
Do rigid bodies with force add force to other objects? 0 Answers
How can i initiate an object in parabolic motion without using gravity using Rigidbody2D? 1 Answer