I basically need to stop the Torque and Force commands from executing once the object attached to the script collides.
I’ve tried the following but still get errors:
this.rigidbody.AddForce = false;
this.rigidbody.AddTorque = false;
this.rigidbody.AddForce = null;
this.rigidbody.AddTorque = null;
Note: Also tried adding “verctor3.zero;”
This is the script. I am not the original author.
using UnityEngine;
using System.Collections;
public class GameplayCake : MonoBehaviour {
protected bool landed = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void startFalling(){
this.rigidbody.useGravity = true;
this.gameObject.transform.parent = null;
this.rigidbody.AddForce (0, 1500, 10);
this.rigidbody.AddTorque (200, 10, 10);
}
public bool hasLanded(){
return landed;
}
void OnTriggerEnter(Collider other) {
this.rigidbody.useGravity = false;
this.rigidbody.AddForce = false;
this.rigidbody.AddTorque = false;
this.rigidbody.velocity = Vector3.zero;
gameObject.transform.parent = other.gameObject.transform;
landed = true;
}
}