unity how to add force
public Rigidbody rb;
if(Input.GetKey(KeyCode.W))
{
rb.AddForce(100, 0, 0);
}
unity how to add force
public Rigidbody rb;
if(Input.GetKey(KeyCode.W))
{
rb.AddForce(100, 0, 0);
}
remove force unity
using UnityEngine;
public class MyObject : MonoBehaviour
{
private RigidBody m_rb;
void Start()
{
m_rb = GetComponent<RigidBody>();
}
// Do it in FixedUpdate() if it's triggered by physics (collision-based for
// example), Update() otherwise.
void FixedUpdate()
{
if(yourCondition)
{
m_rb.velocity = Vector3.zero;
}
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us